From 338224ef6becead193d8b6bd6f4a43604db7f6d0 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 11 Mar 2024 13:25:04 -0300 Subject: [PATCH] =?UTF-8?q?Working=20Docker=20build=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 + apps/api/src/server.ts | 2 +- apps/web/astro.config.mjs | 7 +++++-- apps/web/src/services/api/page.service.ts | 4 +++- docker-compose.yml | 25 +++++++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index d70ebeb..5a8c99e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ COPY . . RUN pnpm install ENV PAYLOAD_CONFIG_PATH=src/payload.config.ts +ENV PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000 RUN pnpm build CMD ["pnpm", "serve"] diff --git a/apps/api/src/server.ts b/apps/api/src/server.ts index 365c24b..428ae32 100644 --- a/apps/api/src/server.ts +++ b/apps/api/src/server.ts @@ -9,7 +9,7 @@ app.get("/", (_, res) => { }); const PORT = Number(process.env.PAYLOAD_PORT) ?? 3000; -const HOST = process.env.PAYLOAD_ADDRESS ?? 'localhost'; +const HOST = process.env.PAYLOAD_HOST ?? 'localhost'; const start = async () => { // Initialize Payload diff --git a/apps/web/astro.config.mjs b/apps/web/astro.config.mjs index 855273e..1e0f364 100644 --- a/apps/web/astro.config.mjs +++ b/apps/web/astro.config.mjs @@ -9,16 +9,19 @@ export default defineConfig({ integrations: [mdx(), tailwind(), svelte()], server: { port: parseInt(process.env.ASTRO_PORT ?? "3000"), + // FIXME 3wc: seems to be ignored? + hostname: process.env.ASTRO_HOST ?? "0.0.0.0", }, output: "server", adapter: node({ mode: "standalone", }), vite: { + // FIXME 3wc: shouldn't need to hardcode this define: { "import.meta.env.PAYLOAD_PUBLIC_SERVER_URL": JSON.stringify( - process.env.PAYLOAD_PUBLIC_SERVER_URL, - ), + "http://api:3001" + ) }, }, }); diff --git a/apps/web/src/services/api/page.service.ts b/apps/web/src/services/api/page.service.ts index b85bf04..ea9772c 100644 --- a/apps/web/src/services/api/page.service.ts +++ b/apps/web/src/services/api/page.service.ts @@ -2,7 +2,9 @@ import type { Page } from "@turbopress/api/types"; import { getPayloadCollection } from "./api.service"; export async function getPageCollection(query: any = null) { - const url = `${import.meta.env.PAYLOAD_PUBLIC_SERVER_URL}/api/pages`; + // FIXME 3wc: shouldn't need to hardcode this?! + //const url = `${import.meta.env.PAYLOAD_PUBLIC_SERVER_URL}/api/pages`; + const url = `http://api:3001/api/pages`; return getPayloadCollection(url, query); } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..92647f2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +--- +version: "3" + +services: + api: + image: justice-equity-technology:3a0b940 + ports: + - 3001:3001 + command: pnpm serve:api + env_file: .env + web: + image: justice-equity-technology:3a0b940 + ports: + - 3000:3000 + command: pnpm serve:web + env_file: .env + db: + image: mongo:latest + ports: + - 27017:27017 + volumes: + - mongo:/data + +volumes: + mongo: