feat: add docker compose
This commit is contained in:
parent
b09da4fca0
commit
73200c9ca3
6
.env.example
Normal file
6
.env.example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
NODE_PORT=3000
|
||||||
|
NODE_ENV=dev
|
||||||
|
DB_HOST=localhost
|
||||||
|
DB_NAME=briques_db
|
||||||
|
DB_USER=briques_llm
|
||||||
|
DB_PASSWORD=briques_password_2025
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
**/.env
|
7
back-end/.env.example
Normal file
7
back-end/.env.example
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
NODE_ENV="dev"
|
||||||
|
|
||||||
|
DB_HOST="postgres"
|
||||||
|
DB_NAME="briques"
|
||||||
|
DB_USER="briques_db"
|
||||||
|
DB_PASSWORD="briques_password"
|
||||||
|
DB_PORT=5432
|
43
back-end/Dockerfile.back
Normal file
43
back-end/Dockerfile.back
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Start from NodeJS image
|
||||||
|
FROM node:22-alpine
|
||||||
|
|
||||||
|
# Workdir definition
|
||||||
|
WORKDIR /usr/src/back
|
||||||
|
|
||||||
|
# Environment declaration variables
|
||||||
|
ARG NODE_ENV="dev"
|
||||||
|
ARG DB_HOST="postgres"
|
||||||
|
ARG DB_NAME="briques"
|
||||||
|
ARG DB_USER="briques_db"
|
||||||
|
ARG DB_PASSWORD="briques_password"
|
||||||
|
ARG 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
|
||||||
|
|
||||||
|
# Compilation des fichiers TypeScript
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Review permissions
|
||||||
|
RUN chown -R node:node ./
|
||||||
|
RUN chmod -R u=rwx,g=,o= ./
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Start app
|
||||||
|
CMD ["pm2", "start", "dist/app.js", "--no-daemon"]
|
5
back-end/nodemon.json
Normal file
5
back-end/nodemon.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"watch": ["src"],
|
||||||
|
"ext": "ts,json",
|
||||||
|
"exec": "ts-node ./src/index.ts"
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "dist/app.js",
|
"main": "dist/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"startonly": "node dist/app.js",
|
||||||
"start": "tsc && node dist/app.js",
|
"start": "tsc && node dist/app.js",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
32
docker-compose.yml
Normal file
32
docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
services:
|
||||||
|
database:
|
||||||
|
hostname: database
|
||||||
|
container_name: briques_postgres
|
||||||
|
image: postgres
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=${DB_NAME}
|
||||||
|
- POSTGRES_USER=${DB_USER}
|
||||||
|
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- database:/var/lib/postgresql/data
|
||||||
|
back:
|
||||||
|
hostname: back
|
||||||
|
container_name: briques_back
|
||||||
|
build:
|
||||||
|
context: ./back-end
|
||||||
|
dockerfile: Dockerfile.back
|
||||||
|
args:
|
||||||
|
- NODE_ENV=${NODE_ENV}
|
||||||
|
- DB_HOST=database
|
||||||
|
- DB_NAME=${DB_NAME}
|
||||||
|
- DB_USER=${DB_USER}
|
||||||
|
- DB_PORT=5432
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- '${NODE_PORT}:3000'
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database:
|
Loading…
x
Reference in New Issue
Block a user