Build backend in docker for production with env vars

This commit is contained in:
Ricardo Paes
2022-02-06 15:02:04 -03:00
parent 1e267507dd
commit 9a54297efd
6 changed files with 93 additions and 1 deletions

5
backend/.dockerignore Normal file
View File

@@ -0,0 +1,5 @@
.git
*Dockerfile*
*docker-compose*
node_modules
dist

23
backend/Dockerfile Normal file
View 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

View File

@@ -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
}
});