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/README.md b/README.md index 8b3891e26..89dd1ab15 100644 --- a/README.md +++ b/README.md @@ -5,26 +5,31 @@ 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... - 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) 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 ``` @@ -34,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 @@ -41,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 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 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/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 diff --git a/infra/dev/front/Dockerfile b/infra/dev/front/Dockerfile index 971cf9994..7312cd322 100644 --- a/infra/dev/front/Dockerfile +++ b/infra/dev/front/Dockerfile @@ -1,13 +1,16 @@ -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 && \ 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..5eb7b18fa 100644 --- a/infra/dev/server/Dockerfile +++ b/infra/dev/server/Dockerfile @@ -1,12 +1,16 @@ -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 && \ 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 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 ./