From d2c6a71c9eea3db673969159c51de9c39b052f3f Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Tue, 25 Apr 2023 17:47:15 +0200 Subject: [PATCH] Fix server local build (#75) * Fix server local build * Build docs locally and for prod --------- Co-authored-by: Charles Bochet --- docs/package.json | 2 +- infra/dev/Makefile | 1 + infra/dev/docker-compose.yml | 14 ++++++++++++-- infra/dev/docs/Dockerfile | 11 +++++++++++ infra/dev/server/Dockerfile | 3 ++- infra/prod/docs/Dockerfile | 13 +++++++++++++ 6 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 infra/dev/docs/Dockerfile create mode 100644 infra/prod/docs/Dockerfile diff --git a/docs/package.json b/docs/package.json index fbecf0e0a2..d3dc44305d 100644 --- a/docs/package.json +++ b/docs/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "docusaurus": "docusaurus", - "start": "docusaurus start", + "start": "docusaurus start --host 0.0.0.0", "build": "docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", diff --git a/infra/dev/Makefile b/infra/dev/Makefile index 9afd5b0ea2..e99b6f29a4 100644 --- a/infra/dev/Makefile +++ b/infra/dev/Makefile @@ -2,6 +2,7 @@ build: ## @docker-compose down docker volume rm dev_twenty_node_modules_front || true docker volume rm dev_twenty_node_modules_server || true + docker volume rm dev_twenty_node_modules_docs || true docker-compose build up: ## diff --git a/infra/dev/docker-compose.yml b/infra/dev/docker-compose.yml index 6b76850bae..8fe5a2d0de 100644 --- a/infra/dev/docker-compose.yml +++ b/infra/dev/docker-compose.yml @@ -74,7 +74,7 @@ services: - "1025:1025" - "8025:8025" twenty-server: - build: + build: context: ../.. dockerfile: ./infra/dev/server/Dockerfile ports: @@ -87,6 +87,15 @@ services: SERVER_DATABASE_URL: ${SERVER_DATABASE_URL} depends_on: - postgres + twenty-docs: + build: + context: ../.. + dockerfile: ./infra/dev/docs/Dockerfile + ports: + - "5000:3000" + volumes: + - ../../docs:/app/docs + - twenty_node_modules_docs:/app/docs/node_modules postgres: build: ./postgres volumes: @@ -98,4 +107,5 @@ services: volumes: db_data: twenty_node_modules_front: - twenty_node_modules_server: \ No newline at end of file + twenty_node_modules_server: + twenty_node_modules_docs: \ No newline at end of file diff --git a/infra/dev/docs/Dockerfile b/infra/dev/docs/Dockerfile new file mode 100644 index 0000000000..b1de13f606 --- /dev/null +++ b/infra/dev/docs/Dockerfile @@ -0,0 +1,11 @@ +FROM node:18.16.0-alpine as docs + +WORKDIR /app/docs + +COPY ../../docs/package.json . +COPY ../../docs/package-lock.json . +RUN npm install + +COPY ../../docs . + +CMD ["npm", "run", "start"] diff --git a/infra/dev/server/Dockerfile b/infra/dev/server/Dockerfile index 7ff99af6a9..139d879b7d 100644 --- a/infra/dev/server/Dockerfile +++ b/infra/dev/server/Dockerfile @@ -9,8 +9,9 @@ WORKDIR /app/server COPY ../../server/package.json . COPY ../../server/package-lock.json . RUN npm install -RUN npx prisma generate +COPY ../../server/src/database/schema.prisma ./src/database/schema.prisma +RUN npx prisma generate COPY ../../server . diff --git a/infra/prod/docs/Dockerfile b/infra/prod/docs/Dockerfile new file mode 100644 index 0000000000..28b46b95c0 --- /dev/null +++ b/infra/prod/docs/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18.16.0-alpine as docs + +WORKDIR /app/docs + +COPY ../../docs/package.json . +COPY ../../docs/package-lock.json . +RUN npm install + +COPY ../../docs . + +RUN npm install -g serve + +CMD ["serve", "-s", "build"]