Docker setup.
This commit is contained in:
parent
6756f99c9b
commit
88e6000755
20
Dockerfile.common
Normal file
20
Dockerfile.common
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# ---------- minimal Node runtime ----------
|
||||||
|
FROM node:20-slim
|
||||||
|
|
||||||
|
# 1. safe work dir
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 2. install prod deps only
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --omit=dev --ignore-scripts
|
||||||
|
|
||||||
|
# 3. copy source
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# 4. expose port placeholder (overridden in child files)
|
||||||
|
ARG APPPORT=5000
|
||||||
|
ENV PORT=$APPPORT
|
||||||
|
EXPOSE $APPPORT
|
||||||
|
|
||||||
|
# 5. start
|
||||||
|
CMD ["npm","start"]
|
9
Dockerfile.server
Normal file
9
Dockerfile.server
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ARG APPPORT=5000
|
||||||
|
FROM --platform=$TARGETPLATFORM node:20-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --omit=dev --ignore-scripts
|
||||||
|
COPY . .
|
||||||
|
ENV PORT=5000
|
||||||
|
EXPOSE 5000
|
||||||
|
CMD ["npm","run","server"]
|
9
Dockerfile.server2
Normal file
9
Dockerfile.server2
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ARG APPPORT=5001
|
||||||
|
FROM --platform=$TARGETPLATFORM node:20-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --omit=dev --ignore-scripts
|
||||||
|
COPY . .
|
||||||
|
ENV PORT=5001
|
||||||
|
EXPOSE 5001
|
||||||
|
CMD ["npm","run","server2"]
|
13
Dockerfile.server3
Normal file
13
Dockerfile.server3
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
ARG APPPORT=5002
|
||||||
|
FROM --platform=$TARGETPLATFORM node:20-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN apt-get update -y && \
|
||||||
|
apt-get install -y --no-install-recommends python3 git && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --omit=dev --ignore-scripts
|
||||||
|
COPY . .
|
||||||
|
ENV PORT=5002
|
||||||
|
EXPOSE 5002
|
||||||
|
CMD ["npm","run","server3"]
|
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
image: us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo/server:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
|
||||||
|
server2:
|
||||||
|
image: us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo/server2:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "5001:5001"
|
||||||
|
|
||||||
|
server3:
|
||||||
|
image: us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo/server3:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "5002:5002"
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.27
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- server
|
||||||
|
- server2
|
||||||
|
- server3
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
13
nginx.conf
Normal file
13
nginx.conf
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
events {}
|
||||||
|
http {
|
||||||
|
upstream backend5000 { server server:5000; }
|
||||||
|
upstream backend5001 { server server2:5001; }
|
||||||
|
upstream backend5002 { server server3:5002; }
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
location /api1/ { proxy_pass http://backend5000/; }
|
||||||
|
location /api2/ { proxy_pass http://backend5001/; }
|
||||||
|
location /api3/ { proxy_pass http://backend5002/; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user