Dev and deploy setup revision (#604)

* revise dockerfiles

* make nginx to proxy requests when static files are absent
This commit is contained in:
Akshay 2021-08-26 20:34:30 +05:30 committed by GitHub
parent 91b32adaed
commit c128d94b1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 38 deletions

View file

@ -1,6 +1,4 @@
# frontend/*
app/*
docs/*
tmp/*
server/node_modules/*
server/dist/*
**/node_modules/*
**/dist/*

View file

@ -26,9 +26,8 @@ services:
- 3000
env_file: .env
environment:
RAILS_LOG_TO_STDOUT: "true"
SERVE_CLIENT: "false"
command: ['npm', 'run', '--prefix', 'server', 'start:prod']
command: npm run start:prod
volumes:
certs:

View file

@ -1,5 +1,6 @@
# pull official base image
FROM node:14.17.0-alpine AS builder
FROM node:14.17.3-alpine AS builder
ENV NODE_ENV=production
# set working directory
WORKDIR /app
@ -11,9 +12,9 @@ ENV PATH /app/node_modules/.bin:$PATH
ENV NODE_OPTIONS="--max-old-space-size=2048"
# install app dependencies
COPY package.json package-lock.json ./
COPY ./frontend/package.json ./frontend/package-lock.json ./
RUN npm install --only=production
COPY . .
COPY ./frontend .
RUN NODE_ENV=production npm run-script build
@ -29,6 +30,6 @@ RUN mkdir /etc/resty-auto-ssl /var/log/openresty /var/www /etc/fallback-certs
COPY --from=builder /app/build /var/www
COPY ./config/nginx.conf.template /etc/openresty/nginx.conf.template
COPY ./config/entrypoint.sh /entrypoint.sh
COPY ./frontend/config/nginx.conf.template /etc/openresty/nginx.conf.template
COPY ./frontend/config/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

View file

@ -1,5 +1,7 @@
# pull official base image
FROM node:14.17.0-alpine
FROM node:14.17.3-alpine
ENV NODE_ENV=development
# set working directory
WORKDIR /app
@ -18,7 +20,6 @@ RUN npm install react-scripts@3.4.1 -g --silent
# add app
COPY . ./
# start app
CMD ["npm", "start"]

View file

@ -1,4 +1,4 @@
FROM node:14.17.0-buster
FROM node:14.17.3-buster
# Fix for JS heap limit allocation issue
ENV NODE_OPTIONS="--max-old-space-size=2048"

View file

@ -1,5 +1,7 @@
FROM node:14.17.3-buster
ENV NODE_ENV=production
# Fix for JS heap limit allocation issue
ENV NODE_OPTIONS="--max-old-space-size=2048"
@ -8,17 +10,15 @@ RUN apt update && apt install -y \
postgresql \
freetds-dev
RUN npm install -g @nestjs/cli
RUN mkdir -p /app
WORKDIR /app
ENV NODE_ENV=production
# Building ToolJet server
COPY ./server/package.json ./server/package-lock.json ./server/
RUN npm --prefix server install
COPY ./server/ ./server/
RUN npm install -g @nestjs/cli
RUN npm --prefix server run build
COPY ./server/package.json ./server/package-lock.json ./
RUN npm install --only=production
COPY ./server/ ./
RUN npm run build
COPY ./docker/ ./docker/
RUN ["chmod", "755", "./server/entrypoint.sh"]
RUN ["chmod", "755", "./entrypoint.sh"]

View file

@ -1,5 +1,7 @@
# pull official base image
FROM node:14.17.0-buster
FROM node:14.17.3-buster
ENV NODE_ENV=development
RUN apt update && apt install -y \
build-essential \
@ -11,13 +13,8 @@ WORKDIR /app
COPY ./server/package.json ./server/package-lock.json ./
RUN npm install
ENV NODE_ENV=development
COPY ./server/ ./
COPY ./docker/ ./docker/
COPY ./.env ../.env
COPY ./.env.test ../.env.test

View file

@ -78,9 +78,9 @@ We recommend:
5. ToolJet server is built using NestJS and the data such as application definitions are persisted on a postgres database. You have to create and migrate the database if building for the first time.
```bash
docker-compose run server npm run db:create
docker-compose run server npm run db:migrate
docker-compose run server npm run db:seed
docker-compose run --rm server npm run db:create
docker-compose run --rm server npm run db:migrate
docker-compose run --rm server npm run db:seed
```
6. Run ToolJet
@ -147,25 +147,25 @@ Test config picks up config from `.env.test` file at the root of the project.
Run the following command to create and migrate data for test db
```bash
docker-compose run -e NODE_ENV=test server npm run db:create
docker-compose run -e NODE_ENV=test server npm run db:migrate
docker-compose run --rm -e NODE_ENV=test server npm run db:create
docker-compose run --rm -e NODE_ENV=test server npm run db:migrate
```
To run the unit tests
```bash
$ docker-compose run server npm run test
$ docker-compose --rm run server npm run test
```
To run e2e tests
```bash
docker-compose run server npm run test:e2e
docker-compose run --rm server npm run test:e2e
```
To run a specific unit test
```bash
docker-compose run server npm run test <path-to-file>
docker-compose run --rm server npm run test <path-to-file>
```
## Troubleshooting

View file

@ -54,9 +54,19 @@ http
ssl_certificate /etc/fallback-certs/resty-auto-ssl-fallback.crt;
ssl_certificate_key /etc/fallback-certs/resty-auto-ssl-fallback.key;
location /
{
root /var/www;
try_files $uri $uri/ /index.html @proxy;
error_page 405 @proxy;
}
location /api/
{
try_files /_bypass_to_proxy @proxy;
}
location @proxy {
proxy_pass http://${SERVER_HOST}:3000;
proxy_redirect off;
proxy_set_header Host $host;
@ -76,6 +86,17 @@ http
location /
{
root /var/www;
try_files $uri $uri/ /index.html @proxy;
error_page 405 @proxy;
}
location /api/
{
try_files /_bypass_to_proxy @proxy;
}
location @proxy {
proxy_pass http://${SERVER_HOST}:3000;
proxy_redirect off;
proxy_set_header Host $host;