diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0d8de4c --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d70ebeb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:21-alpine3.18 +RUN npm i -g pnpm turbo + +WORKDIR /app +COPY . . + +RUN pnpm install +ENV PAYLOAD_CONFIG_PATH=src/payload.config.ts +RUN pnpm build + +CMD ["pnpm", "serve"] diff --git a/apps/api/package.json b/apps/api/package.json index 4b6dba5..70b17fd 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -17,7 +17,7 @@ "dependencies": { "dotenv": "^8.2.0", "express": "^4.17.1", - "payload": "latest", + "payload": "1.12.0", "@payloadcms/plugin-seo": "latest", "@payloadcms/plugin-cloud-storage": "latest", "@aws-sdk/client-s3": "latest", diff --git a/apps/api/src/server.ts b/apps/api/src/server.ts index 5298e66..3386429 100644 --- a/apps/api/src/server.ts +++ b/apps/api/src/server.ts @@ -8,6 +8,9 @@ app.get("/", (_, res) => { res.redirect("/admin"); }); +const PORT = process.env.PAYLOAD_PORT ?? 3000, +const HOST = process.env.PAYLOAD_ADDRESS ?? 'localhost', + const start = async () => { // Initialize Payload await payload.init({ @@ -24,7 +27,13 @@ const start = async () => { // Add your own express routes here - app.listen(process.env.PAYLOAD_PORT ?? 3000); + app.listen( + PORT, + HOST, + () => { + console.log(`Server running at http://${HOST}:${PORT}/`); + } + ); }; start();