Интегрирован Docker compose

This commit is contained in:
Данил 2024-10-09 14:45:20 +03:00
parent de44af6881
commit bf2d6e67cc
9 changed files with 153 additions and 1 deletions

4
.env-sample Normal file
View file

@ -0,0 +1,4 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=my_password
POSTGRES_DB=my_database
DB_HOST=postgres

2
.gitignore vendored
View file

@ -2,5 +2,7 @@
CertSSL/
charts/
node_modules/
postgres-data/
config.yaml
.env

View file

@ -0,0 +1,38 @@
FROM node:20 as shared-config
# Устанавливаем зависимости shared/config
WORKDIR /
COPY ./shared/config/package*.json .
RUN npm install
FROM node:20 as shared-database
# Устанавливаем зависимости shared/database
WORKDIR /
COPY ./shared/database/package*.json .
RUN npm install
FROM node:20 as shared-logger
# Устанавливаем зависимости shared/logger
WORKDIR /
COPY ./shared/logger/package*.json .
RUN npm install
FROM node:20 as collect-currency
WORKDIR /
# Устанавливаем зависимости server
COPY ./collect-currency/package*.json ./
RUN npm install
# Копируем зависимости shared
COPY --from=shared-config /node_modules /node_modules
COPY --from=shared-database /node_modules /node_modules
COPY --from=shared-logger /node_modules /node_modules
# Копируем все остальные файлы
COPY ./collect-currency/ ./
COPY ./shared/ ./shared/
EXPOSE 3000
CMD ["node", "main.js"]

38
Dockerfile-server Normal file
View file

@ -0,0 +1,38 @@
FROM node:20 as shared-config
# Устанавливаем зависимости shared/config
WORKDIR /
COPY ./shared/config/package*.json .
RUN npm install
FROM node:20 as shared-database
# Устанавливаем зависимости shared/database
WORKDIR /
COPY ./shared/database/package*.json .
RUN npm install
FROM node:20 as shared-logger
# Устанавливаем зависимости shared/logger
WORKDIR /
COPY ./shared/logger/package*.json .
RUN npm install
FROM node:20 as server
WORKDIR /
# Устанавливаем зависимости server
COPY ./server/package*.json ./
RUN npm install
# Копируем зависимости shared
COPY --from=shared-config /node_modules /node_modules
COPY --from=shared-database /node_modules /node_modules
COPY --from=shared-logger /node_modules /node_modules
# Копируем все остальные файлы
COPY ./server/ ./
COPY ./shared/ ./shared/
EXPOSE 3000
CMD ["node", "main.js"]

2
chart/.dockerignore Normal file
View file

@ -0,0 +1,2 @@
mypy.ini
pylintrc

12
chart/Dockerfile Normal file
View file

@ -0,0 +1,12 @@
FROM python:3.12
WORKDIR /
COPY ./requirements.txt ./
RUN pip3 install --no-cache-dir --upgrade -r ./requirements.txt
COPY . .
EXPOSE 3030
CMD ["python", "main.py"]

View file

@ -0,0 +1 @@
node_modules/

54
docker-compose.yaml Normal file
View file

@ -0,0 +1,54 @@
version: '3.8'
services:
server:
build:
context: ./
dockerfile: Dockerfile-server
restart: unless-stopped
ports:
- '0.0.0.0:3000:3000'
volumes:
- './CertSSL:/CertSSL'
- './config.yaml:/config.yaml'
depends_on:
- postgres
chart:
build:
context: ./chart
restart: unless-stopped
ports:
- '0.0.0.0:3030:3030'
volumes:
- './CertSSL:/CertSSL'
- './config.yaml:/config.yaml'
depends_on:
- postgres
collect-currency:
build:
context: ./
dockerfile: Dockerfile-collect-currency
restart: unless-stopped
volumes:
- './config.yaml:/config.yaml'
depends_on:
- postgres
postgres:
image: postgres:latest
restart: unless-stopped
env_file: .env
volumes:
- ./postgres-data:/var/lib/postgresql/data
volumes:
server:
driver: local
chart:
driver: local
collect-currency:
driver: local
postgres:
driver: local

1
server/.dockerignore Normal file
View file

@ -0,0 +1 @@
node_modules/