Features: 1) Add Dockerfile for building and running storefront application; 2) Introduce multi-stage build with separation of development and runtime environments; 3) Include environment variable management and non-root user setup;

Fixes: 1) Update dependencies in `package-lock.json` with the latest versions to address compatibility issues;

Extra: 1) Remove unused dependencies and redundant package references from `package-lock.json` for optimization; 2) Improve scripts and permission setups in Dockerfile for clarity and security.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-09-13 14:13:26 +03:00
parent dc19e1f0a0
commit b68911006b
8 changed files with 4169 additions and 3402 deletions

View file

@ -12,6 +12,7 @@ coverage.*
*.py,cover
nosetests.xml
desktop.ini
tmp/
# Cache directories
__pycache__/
@ -50,6 +51,8 @@ wheels/
share/python-wheels/
pip-log.txt
pip-delete-this-directory.txt
storefront/node_modules/
storefront/.nuxt
# Git
.git/

View file

@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1
FROM node:22-bookworm-slim AS build
WORKDIR /app
ENV NODE_ENV=development
COPY ./storefront/package.json ./storefront/package-lock.json ./
RUN npm ci --include=optional
COPY ./storefront ./
RUN npm run build
FROM node:22-bookworm-slim AS runtime
WORKDIR /app
ENV HOST=0.0.0.0
ENV PORT=3000
ENV NODE_ENV=production
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
RUN addgroup --system --gid 1001 nodeapp \
&& adduser --system --uid 1001 --ingroup nodeapp --home /home/nodeapp nodeapp
USER nodeapp
COPY --from=build /app/.output/ ./
RUN install -d -m 0755 -o nodeapp -g nodeapp /home/nodeapp \
&& printf '#!/bin/sh\nif [ \"$DEBUG\" = \"1\" ]; then export NODE_ENV=development; else export NODE_ENV=production; fi\nexec node /app/server/index.mjs\n' > /home/nodeapp/start.sh \
&& chown nodeapp:nodeapp /home/nodeapp/start.sh \
&& chmod +x /home/nodeapp/start.sh
USER nodeapp
CMD ["sh", "/home/nodeapp/start.sh"]

View file

@ -9,7 +9,7 @@ services:
container_name: app
build:
context: .
dockerfile: ./Dockerfiles/Dockerfile.app
dockerfile: ./Dockerfiles/app.Dockerfile
restart: always
volumes:
- .:/app
@ -128,7 +128,7 @@ services:
container_name: worker
build:
context: .
dockerfile: ./Dockerfiles/Dockerfile.worker
dockerfile: ./Dockerfiles/worker.Dockerfile
restart: always
volumes:
- .:/app
@ -156,7 +156,7 @@ services:
container_name: stock_updater
build:
context: .
dockerfile: ./Dockerfiles/Dockerfile.stock_updater
dockerfile: ./Dockerfiles/stock_updater.Dockerfile
restart: always
volumes:
- .:/app
@ -184,7 +184,7 @@ services:
container_name: beat
build:
context: .
dockerfile: ./Dockerfiles/Dockerfile.beat
dockerfile: ./Dockerfiles/beat.Dockerfile
restart: always
volumes:
- .:/app
@ -220,6 +220,29 @@ services:
- --web.config.file=/etc/prometheus/web.yml
logging: *default-logging
storefront:
container_name: storefront
build:
context: .
dockerfile: ./Dockerfiles/storefront.Dockerfile
args:
- DEBUG=${DEBUG}
restart: always
env_file:
- .env
environment:
- NODE_ENV=${DEBUG:+development}
- NODE_ENV=${DEBUG:-production}
- NUXT_HOST=0.0.0.0
- NUXT_PORT=3000
- NUXT_DEVTOOLS_ENABLED=${DEBUG}
ports:
- "3000:3000"
depends_on:
app:
condition: service_started
logging: *default-logging
volumes:
es-data:

File diff suppressed because it is too large Load diff