mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-17 19:37:02 +00:00
Build backend in docker for production with env vars
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.docker/data/
|
||||
5
backend/.dockerignore
Normal file
5
backend/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
||||
.git
|
||||
*Dockerfile*
|
||||
*docker-compose*
|
||||
node_modules
|
||||
dist
|
||||
23
backend/Dockerfile
Normal file
23
backend/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM node:14 as build-deps
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
ENV DOCKERIZE_VERSION v0.6.1
|
||||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENTRYPOINT dockerize -wait tcp://${DB_HOST}:3306 \
|
||||
&& npx sequelize db:migrate \
|
||||
&& node dist/server.js
|
||||
@@ -46,7 +46,9 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<Session> => {
|
||||
const wbot: Session = new Client({
|
||||
session: sessionCfg,
|
||||
puppeteer: {
|
||||
executablePath: process.env.CHROME_BIN || undefined
|
||||
executablePath: process.env.CHROME_BIN || undefined,
|
||||
// @ts-ignore
|
||||
browserWSEndpoint: process.env.CHROME_WS || undefined
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
56
docker-compose.yaml
Normal file
56
docker-compose.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
version: '3'
|
||||
|
||||
networks:
|
||||
whaticket:
|
||||
|
||||
services:
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: ./Dockerfile
|
||||
environment:
|
||||
- DB_HOST=mysql
|
||||
- DB_USER=root
|
||||
- DB_PASS=${MYSQL_ROOT_PASSWORD:-strongpassword}
|
||||
- DB_NAME=${MYSQL_DATABASE:-whaticket}
|
||||
- JWT_SECRET=${JWT_SECRET:-3123123213123}
|
||||
- JWT_REFRESH_SECRET=${JWT_REFRESH_SECRET:-75756756756}
|
||||
- CHROME_WS=ws://chrome:3000
|
||||
ports:
|
||||
- 8080:3000
|
||||
networks:
|
||||
- whaticket
|
||||
|
||||
frontend:
|
||||
ports:
|
||||
- 3000:80
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: ./Dockerfile
|
||||
environment:
|
||||
- URL_BACKEND=http://backend:3000/
|
||||
networks:
|
||||
- whaticket
|
||||
|
||||
mysql:
|
||||
image: mariadb:latest
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
|
||||
ports:
|
||||
- 3306:3306
|
||||
volumes:
|
||||
- ./.docker/data/:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASE:-whaticket}
|
||||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-strongpassword}
|
||||
- TZ=${TZ:-America/Fortaleza}
|
||||
restart: always
|
||||
networks:
|
||||
- whaticket
|
||||
|
||||
chrome:
|
||||
image: browserless/chrome:latest
|
||||
environment:
|
||||
- MAX_CONCURRENT_SESSIONS=10
|
||||
networks:
|
||||
- whaticket
|
||||
5
frontend/.dockerignore
Normal file
5
frontend/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
||||
.git
|
||||
*Dockerfile*
|
||||
*docker-compose*
|
||||
node_modules
|
||||
build
|
||||
Reference in New Issue
Block a user