From e8f85f2a29dbe5e80f6c5956b5dbcaef232bacdc Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 18 Apr 2023 15:23:47 +0200 Subject: [PATCH 1/6] bugfix: sync server files in server container --- infra/dev/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/dev/docker-compose.yml b/infra/dev/docker-compose.yml index 77aa1f409..70ac45478 100644 --- a/infra/dev/docker-compose.yml +++ b/infra/dev/docker-compose.yml @@ -36,7 +36,7 @@ services: ports: - "3000:3000" volumes: - - ../../front:/app/front + - ../../server:/app/server - twenty_node_modules_server:/app/server/node_modules depends_on: - postgres From babd9208e781beede22d5f5453faa19d9247d953 Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 18 Apr 2023 15:31:58 +0200 Subject: [PATCH 2/6] chore: change way to store npm secrets --- .gitignore | 1 + front/.env.example | 3 +-- front/.npmrc | 2 -- front/.npmrc.example | 2 ++ 4 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 front/.npmrc create mode 100644 front/.npmrc.example diff --git a/.gitignore b/.gitignore index 594d0dc3e..4b8801edb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vscode/* **/**/.env +**/**/.npmrc .DS_Store diff --git a/front/.env.example b/front/.env.example index 544d0d4c0..b4ab84278 100644 --- a/front/.env.example +++ b/front/.env.example @@ -1,2 +1 @@ -REACT_APP_API_URL=http://localhost:3000 -FONTAWESOME_NPM_AUTH_TOKEN=REPLACE_ME \ No newline at end of file +REACT_APP_API_URL=http://localhost:3000 \ No newline at end of file diff --git a/front/.npmrc b/front/.npmrc deleted file mode 100644 index 1e023808d..000000000 --- a/front/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -@fortawesome:registry=https://npm.fontawesome.com/ -//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN} \ No newline at end of file diff --git a/front/.npmrc.example b/front/.npmrc.example new file mode 100644 index 000000000..49114eae1 --- /dev/null +++ b/front/.npmrc.example @@ -0,0 +1,2 @@ +@fortawesome:registry=https://npm.fontawesome.com/ +//npm.fontawesome.com/:_authToken=REPLACE_ME \ No newline at end of file From 77c387e14a281abb367e28b222b85c89b1bccd4f Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 18 Apr 2023 15:34:08 +0200 Subject: [PATCH 3/6] chore: update way to store npm secrets --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b3891e26..58297918e 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,10 @@ Twenty development stack is composed of 3 different layers - server: our backend that contain endpoint, crm logic, scripts, jobs... - storages: postgres -## Setup env variables +## Setup env variables and npmrc variables -1. `cp ./infra/dev/.front.env.example ./front/.env` and fill with values +1. `cp ./front/.env.example ./front/.env` and fill with values +2. `cp ./front/.npmrc.example ./front/.npmrc` and fill with values ## Development environment setup with docker-compose (Recommended) From 24a3a9d828f9cdc6f6ef13390a1e25ffb751823a Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 18 Apr 2023 15:37:05 +0200 Subject: [PATCH 4/6] docs: lint readme --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 58297918e..89dd1ab15 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Welcome to Twenty documentation! ## High Level Overview Twenty development stack is composed of 3 different layers + - front: our frontend React app - hasura: our graphql engine exposing our database and server - server: our backend that contain endpoint, crm logic, scripts, jobs... @@ -20,12 +21,15 @@ Twenty development stack is composed of 3 different layers We also provide a containerized environment with Docker and orchestrated with docker-compose in case it is easier for you. This install will also provision a postgres container out of the box. ### Step 1: pre-requesites + Make sure to have the latest Docker and Docker-compose versions installed on your computer. You can run `docker-compose --version` to check if you have docker-compose installed and `docker --version` to check if you have docker installed. ### Step 2: docker build + Build docker containers. The whole setup experience is happening in `infra/dev` folder. Make sure to be in this folder: + ``` cd infra/dev ``` @@ -35,6 +39,7 @@ make build ``` Once this is completed you should have: + - front available on: http://localhost:3001 - hasura available on: http://localhost:8080 - server available on: http://localhost:3000/health @@ -42,7 +47,7 @@ Once this is completed you should have: ### Step 3: IDE setup -If you are using VSCode, please use the `Dev Containers` extension to open the project in a container. This will allow you to run Visual Studio on top of the docker container. This will allow you to run the project without having to install node on your machine. +If you are using VSCode, please use the `Dev Containers` extension to open the project in a container. This will allow you to run Visual Studio on top of the docker container. This will allow you to run the project without having to install node on your machine. ### Note From bba8c592acced070579236d4ef1964491d78b3ae Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 18 Apr 2023 16:17:01 +0200 Subject: [PATCH 5/6] chore: fix build command and improve installation steps --- infra/dev/Makefile | 5 ++++- infra/dev/front/Dockerfile | 7 +++++-- infra/dev/server/Dockerfile | 8 ++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/infra/dev/Makefile b/infra/dev/Makefile index 5568250e0..8dc8bd6a5 100644 --- a/infra/dev/Makefile +++ b/infra/dev/Makefile @@ -1,5 +1,8 @@ build: ## - @docker-compose up --build --force-recreate + @docker-compose down + docker volume rm dev_twenty_node_modules_front || true + docker volume rm dev_twenty_node_modules_server || true + docker-compose build up: ## @docker-compose up -d diff --git a/infra/dev/front/Dockerfile b/infra/dev/front/Dockerfile index 971cf9994..b7d807523 100644 --- a/infra/dev/front/Dockerfile +++ b/infra/dev/front/Dockerfile @@ -5,9 +5,12 @@ RUN apk update && apk upgrade && \ apk add libc6-compat WORKDIR /app/front -COPY ../../front . -RUN export $(xargs <.env) +COPY ../../front/package.json . +COPY ../../front/package-lock.json . +COPY ../../front/.npmrc . RUN npm install +COPY ../../front . + CMD ["npm", "run", "start"] diff --git a/infra/dev/server/Dockerfile b/infra/dev/server/Dockerfile index 20e36ccec..774fc3352 100644 --- a/infra/dev/server/Dockerfile +++ b/infra/dev/server/Dockerfile @@ -5,8 +5,12 @@ RUN apk update && apk upgrade && \ apk add libc6-compat WORKDIR /app/server -COPY ../../server . +COPY ../../server/package.json . +COPY ../../server/package-lock.json . RUN npm install -CMD ["npm", "run", "start"] +COPY ../../server . + + +CMD ["npm", "run", "start"] \ No newline at end of file From 09ee4c91e2759abd08dd32bc97152558e6bb673b Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 18 Apr 2023 16:21:38 +0200 Subject: [PATCH 6/6] chore: fix version of node images --- infra/dev/front/Dockerfile | 2 +- infra/dev/server/Dockerfile | 2 +- infra/prod/front/Dockerfile | 2 +- infra/prod/server/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infra/dev/front/Dockerfile b/infra/dev/front/Dockerfile index b7d807523..7312cd322 100644 --- a/infra/dev/front/Dockerfile +++ b/infra/dev/front/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine as front +FROM node:18.16.0-alpine as front RUN apk update && apk upgrade && \ apk add --no-cache bash git openssh && \ diff --git a/infra/dev/server/Dockerfile b/infra/dev/server/Dockerfile index 774fc3352..5eb7b18fa 100644 --- a/infra/dev/server/Dockerfile +++ b/infra/dev/server/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine as server +FROM node:18.16.0-alpine as server RUN apk update && apk upgrade && \ apk add --no-cache bash git openssh && \ diff --git a/infra/prod/front/Dockerfile b/infra/prod/front/Dockerfile index b0b38c62a..076e0dd31 100644 --- a/infra/prod/front/Dockerfile +++ b/infra/prod/front/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine as front +FROM node:18.16.0-alpine as front ARG FONTAWESOME_NPM_AUTH_TOKEN diff --git a/infra/prod/server/Dockerfile b/infra/prod/server/Dockerfile index 75b622d05..cae775f8b 100644 --- a/infra/prod/server/Dockerfile +++ b/infra/prod/server/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine as server +FROM node:18.16.0-alpine as server COPY ./server/package.json ./ COPY ./server/package-lock.json ./