8 changed files with 106 additions and 0 deletions
@ -0,0 +1,8 @@
|
||||
FROM node:20-alpine |
||||
WORKDIR /app |
||||
COPY package.json package-lock.json* ./ |
||||
RUN npm ci |
||||
COPY . . |
||||
EXPOSE 3001 |
||||
RUN chmod +x docker-entrypoint.sh |
||||
ENTRYPOINT ["./docker-entrypoint.sh"] |
||||
@ -0,0 +1,6 @@
|
||||
#!/bin/sh |
||||
set -e |
||||
echo "Running database migrations…" |
||||
node src/db/migrate.js |
||||
echo "Starting API…" |
||||
exec node src/server.js |
||||
@ -0,0 +1,46 @@
|
||||
# Система тестирования + общий Postgres (Postgres_TG_Bots / hr_postgres_dev). |
||||
# Требуется: сеть hr_postgres_dev_net и поднятый hr_postgres_dev. |
||||
# cd ../Postgres_TG_Bots && docker compose -f docker-compose.dev.yml up -d |
||||
# База clinic_tests: один раз |
||||
# psql "postgresql://hr_bot_user:hrbot123@localhost:5432/postgres" -c "CREATE DATABASE clinic_tests;" |
||||
# |
||||
# Запуск: из каталога TestingWebApp |
||||
# docker compose -f docker-compose.dev.yml up --build |
||||
# UI: http://localhost:8080 ( /api → backend ) |
||||
|
||||
services: |
||||
testing-backend: |
||||
build: |
||||
context: ./backend |
||||
dockerfile: Dockerfile |
||||
container_name: testing_webapp_backend |
||||
environment: |
||||
DATABASE_URL: postgresql://hr_bot_user:hrbot123@hr_postgres_dev:5432/clinic_tests |
||||
JWT_SECRET: ${JWT_SECRET:-testing_webapp_jwt_dev} |
||||
# development: httpOnly-cookie без Secure (иначе на http://localhost:8080 логин не сработает) |
||||
NODE_ENV: development |
||||
FRONTEND_URL: http://localhost:8080 |
||||
# На хосте 3002, если 3001 занят локальным dev-сервером |
||||
ports: |
||||
- "3002:3001" |
||||
networks: |
||||
- app |
||||
- postgres |
||||
|
||||
testing-web: |
||||
build: |
||||
context: ./frontend |
||||
dockerfile: Dockerfile |
||||
container_name: testing_webapp_nginx |
||||
depends_on: |
||||
- testing-backend |
||||
ports: |
||||
- "8080:80" |
||||
networks: |
||||
- app |
||||
|
||||
networks: |
||||
app: |
||||
postgres: |
||||
name: hr_postgres_dev_net |
||||
external: true |
||||
@ -0,0 +1,13 @@
|
||||
# Build SPA |
||||
FROM node:20-alpine AS build |
||||
WORKDIR /app |
||||
COPY package.json package-lock.json* ./ |
||||
RUN npm ci |
||||
COPY . . |
||||
RUN npm run build |
||||
|
||||
# Static + API proxy |
||||
FROM nginx:1.25-alpine |
||||
COPY --from=build /app/dist /usr/share/nginx/html |
||||
COPY nginx-default.conf /etc/nginx/conf.d/default.conf |
||||
EXPOSE 80 |
||||
@ -0,0 +1,18 @@
|
||||
server { |
||||
listen 80; |
||||
server_name _; |
||||
root /usr/share/nginx/html; |
||||
index index.html; |
||||
location / { |
||||
try_files $uri $uri/ /index.html; |
||||
} |
||||
location /api/ { |
||||
proxy_pass http://testing-backend:3001; |
||||
proxy_http_version 1.1; |
||||
proxy_set_header Host $host; |
||||
proxy_set_header X-Real-IP $remote_addr; |
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
proxy_set_header X-Forwarded-Proto $scheme; |
||||
proxy_set_header Cookie $http_cookie; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue