Merge pull request #40 from twentyhq/fix-dev-env

bugfix: sync server files in server container
This commit is contained in:
Sammy Teillet
2023-04-18 16:42:25 +02:00
committed by GitHub
11 changed files with 33 additions and 17 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.vscode/* .vscode/*
**/**/.env **/**/.env
**/**/.npmrc
.DS_Store .DS_Store

View File

@@ -5,26 +5,31 @@ Welcome to Twenty documentation!
## High Level Overview ## High Level Overview
Twenty development stack is composed of 3 different layers Twenty development stack is composed of 3 different layers
- front: our frontend React app - front: our frontend React app
- hasura: our graphql engine exposing our database and server - hasura: our graphql engine exposing our database and server
- server: our backend that contain endpoint, crm logic, scripts, jobs... - server: our backend that contain endpoint, crm logic, scripts, jobs...
- storages: postgres - 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) ## 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. 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 ### 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. 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 ### Step 2: docker build
Build docker containers. Build docker containers.
The whole setup experience is happening in `infra/dev` folder. Make sure to be in this folder: The whole setup experience is happening in `infra/dev` folder. Make sure to be in this folder:
``` ```
cd infra/dev cd infra/dev
``` ```
@@ -34,6 +39,7 @@ make build
``` ```
Once this is completed you should have: Once this is completed you should have:
- front available on: http://localhost:3001 - front available on: http://localhost:3001
- hasura available on: http://localhost:8080 - hasura available on: http://localhost:8080
- server available on: http://localhost:3000/health - server available on: http://localhost:3000/health
@@ -41,7 +47,7 @@ Once this is completed you should have:
### Step 3: IDE setup ### 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 ### Note

View File

@@ -1,2 +1 @@
REACT_APP_API_URL=http://localhost:3000 REACT_APP_API_URL=http://localhost:3000
FONTAWESOME_NPM_AUTH_TOKEN=REPLACE_ME

View File

@@ -1,2 +0,0 @@
@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN}

2
front/.npmrc.example Normal file
View File

@@ -0,0 +1,2 @@
@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=REPLACE_ME

View File

@@ -1,5 +1,8 @@
build: ## 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: ## up: ##
@docker-compose up -d @docker-compose up -d

View File

@@ -36,7 +36,7 @@ services:
ports: ports:
- "3000:3000" - "3000:3000"
volumes: volumes:
- ../../front:/app/front - ../../server:/app/server
- twenty_node_modules_server:/app/server/node_modules - twenty_node_modules_server:/app/server/node_modules
depends_on: depends_on:
- postgres - postgres

View File

@@ -1,13 +1,16 @@
FROM node:18-alpine as front FROM node:18.16.0-alpine as front
RUN apk update && apk upgrade && \ RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh && \ apk add --no-cache bash git openssh && \
apk add libc6-compat apk add libc6-compat
WORKDIR /app/front WORKDIR /app/front
COPY ../../front .
RUN export $(xargs <.env) COPY ../../front/package.json .
COPY ../../front/package-lock.json .
COPY ../../front/.npmrc .
RUN npm install RUN npm install
COPY ../../front .
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]

View File

@@ -1,12 +1,16 @@
FROM node:18-alpine as server FROM node:18.16.0-alpine as server
RUN apk update && apk upgrade && \ RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh && \ apk add --no-cache bash git openssh && \
apk add libc6-compat apk add libc6-compat
WORKDIR /app/server WORKDIR /app/server
COPY ../../server .
COPY ../../server/package.json .
COPY ../../server/package-lock.json .
RUN npm install RUN npm install
CMD ["npm", "run", "start"] COPY ../../server .
CMD ["npm", "run", "start"]

View File

@@ -1,4 +1,4 @@
FROM node:18-alpine as front FROM node:18.16.0-alpine as front
ARG FONTAWESOME_NPM_AUTH_TOKEN ARG FONTAWESOME_NPM_AUTH_TOKEN

View File

@@ -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.json ./
COPY ./server/package-lock.json ./ COPY ./server/package-lock.json ./