refactor: use .env to configure the server in Dockerfile, it uses the .env.production
This commit is contained in:
parent
b42d403031
commit
d95109a86e
5
back-end/.dockerignore
Normal file
5
back-end/.dockerignore
Normal file
@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
dist
|
||||
.env
|
||||
.env.example
|
||||
nodemon.json
|
@ -4,30 +4,14 @@ FROM node:22-alpine
|
||||
# Workdir definition
|
||||
WORKDIR /usr/src/back
|
||||
|
||||
# Environment declaration variables
|
||||
ENV NODE_ENV="dev"
|
||||
ENV DB_HOST="briques_postgres"
|
||||
ENV DB_NAME="briques_db"
|
||||
ENV DB_USER="briques_llm"
|
||||
ENV DB_PASSWORD="briques_password_2025"
|
||||
ENV DB_PORT=5432
|
||||
|
||||
COPY package.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
RUN npm install -g pm2
|
||||
|
||||
# Copy sources
|
||||
COPY . .
|
||||
|
||||
# Setting up environment
|
||||
RUN echo "NODE_ENV=${NODE_ENV}" > .env \
|
||||
&& echo "DB_HOST=${DB_HOST}" >> .env \
|
||||
&& echo "DB_NAME=${DB_NAME}" >> .env \
|
||||
&& echo "DB_USER=${DB_USER}" >> .env \
|
||||
&& echo "DB_PORT=${DB_PORT}" >> .env \
|
||||
&& echo "DB_PASSWORD=${DB_PASSWORD}" >> .env
|
||||
COPY .env.production .env
|
||||
|
||||
# Compilation des fichiers TypeScript
|
||||
RUN npm run build
|
||||
@ -40,5 +24,4 @@ RUN chmod -R u=rwx,g=,o= ./
|
||||
EXPOSE 3000
|
||||
|
||||
# Start app
|
||||
CMD ["npm", "run", "startonly"]
|
||||
#CMD ["pm2", "start", "dist/app.js", "--no-daemon"]
|
||||
CMD ["pm2", "start", "dist/app.js", "--no-daemon"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user