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/*
**/**/.env
**/**/.npmrc
.DS_Store

View File

@@ -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

View File

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

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: ##
@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

View File

@@ -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

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 && \
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"]

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 && \
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"]

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

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-lock.json ./