feat(docker): added in docker build stuff to run this in docker as well as windows service
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
.git
|
||||||
|
.env
|
||||||
dist
|
dist
|
||||||
Dockerfile
|
Dockerfile
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
|
npm-debug.log
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
# ---> Node
|
# ---> Node
|
||||||
|
testFiles
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
41
Dockerfile
41
Dockerfile
@@ -1,23 +1,44 @@
|
|||||||
FROM node:24.12-alpine
|
###########
|
||||||
|
# Stage 1 #
|
||||||
|
###########
|
||||||
|
# Build stage with all dependencies
|
||||||
|
FROM node:24.12-alpine as build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY . .
|
||||||
|
|
||||||
# Install production dependencies only
|
# Install production dependencies only
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
RUN npm build:app
|
RUN npm run build
|
||||||
|
|
||||||
# Copy built app from builder stage
|
###########
|
||||||
COPY --from=builder /app/dist ./dist
|
# Stage 2 #
|
||||||
|
###########
|
||||||
|
# Small final image with only what’s needed to run
|
||||||
|
FROM node:24.12-alpine AS production
|
||||||
|
|
||||||
# Environment variables with defaults
|
WORKDIR /app
|
||||||
ENV PORT=3000
|
|
||||||
ENV DB_USER=admin
|
|
||||||
ENV DB_PASSWORD=changeme
|
|
||||||
|
|
||||||
|
# Copy package files first to install runtime deps
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# curl install
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
# Only install production dependencies
|
||||||
|
RUN npm ci --omit=dev
|
||||||
|
|
||||||
|
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
|
||||||
|
ENV RUNNING_IN_DOCKER=true
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
# start the app up
|
||||||
|
CMD ["npm", "run", "start:docker"]
|
||||||
|
|
||||||
CMD ["node", "dist/index.js"]
|
# Add health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:3000/lst/api/stats || exit 1
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
FROM node:24-alpine AS deps
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package.json ./
|
|
||||||
RUN ls -la /app
|
|
||||||
#RUN mkdir frontend
|
|
||||||
#RUN mkdir lstDocs
|
|
||||||
#RUN mkdir controller
|
|
||||||
#COPY frontend/package*.json ./frontend
|
|
||||||
#COPY lstDocs/package*.json ./lstDocs
|
|
||||||
#COPY controller/index.html ./controller
|
|
||||||
|
|
||||||
RUN npm install
|
|
||||||
#RUN npm run install:front
|
|
||||||
#RUN npm run install:docs
|
|
||||||
|
|
||||||
# Build the Next.js app
|
|
||||||
FROM node:24-alpine AS builder
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
#COPY --from=deps /app/frontend/node_modules ./frontend/node_modules
|
|
||||||
#COPY --from=deps /app/lstDocs/node_modules ./lstDocs/node_modules
|
|
||||||
#COPY --from=deps /app/controller/index.html ./controller/index.html
|
|
||||||
#COPY . ./
|
|
||||||
RUN npm run build:app
|
|
||||||
#RUN npm run build:front
|
|
||||||
#RUN npm run build:docs
|
|
||||||
|
|
||||||
# Final stage
|
|
||||||
FROM node:24-alpine
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
#COPY --from=builder /app/frontend/dist ./frontend/dist
|
|
||||||
#COPY --from=builder /app/lstDocs/build ./lstDocs/build
|
|
||||||
#COPY --from=deps /app/controller/index.html ./controller/index.html
|
|
||||||
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV RUNNING_IN_DOCKER=true
|
|
||||||
ENV PORT=3000
|
|
||||||
EXPOSE 3000
|
|
||||||
CMD ["node", "dist/index.js"]
|
|
||||||
@@ -6,44 +6,45 @@ services:
|
|||||||
container_name: lst_app
|
container_name: lst_app
|
||||||
ports:
|
ports:
|
||||||
#- "${VITE_PORT:-4200}:4200"
|
#- "${VITE_PORT:-4200}:4200"
|
||||||
- "4000:4200"
|
- "3600:3000"
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=development
|
- NODE_ENV=production
|
||||||
# - DATABASE_HOST=host.docker.internal
|
- LOG_LEVEL=info
|
||||||
# - DATABASE_PORT=${DATABASE_PORT}
|
- DATABASE_HOST=host.docker.internal
|
||||||
# - DATABASE_USER=${DATABASE_USER}
|
- DATABASE_PORT=5433
|
||||||
# - DATABASE_PASSWORD=${DATABASE_PASSWORD}
|
- DATABASE_USER=${DATABASE_USER}
|
||||||
# - DATABASE_DB=${DATABASE_DB}
|
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
|
||||||
|
- DATABASE_DB=${DATABASE_DB}
|
||||||
- PROD_SERVER=${PROD_SERVER}
|
- PROD_SERVER=${PROD_SERVER}
|
||||||
- PROD_PLANT_TOKEN=${PROD_PLANT_TOKEN}
|
- PROD_PLANT_TOKEN=${PROD_PLANT_TOKEN}
|
||||||
- PROD_USER=${PROD_USER}
|
- PROD_USER=${PROD_USER}
|
||||||
- PROD_PASSWORD=${PROD_PASSWORD}
|
- PROD_PASSWORD=${PROD_PASSWORD}
|
||||||
# - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
|
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
|
||||||
# - BETTER_AUTH_URL=${BETTER_AUTH_URL}
|
- BETTER_AUTH_URL=${URL}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# for all host including prod servers, plc's, printers, or other de
|
# for all host including prod servers, plc's, printers, or other de
|
||||||
extra_hosts:
|
# extra_hosts:
|
||||||
- "${PROD_SERVER}:${PROD_IP}"
|
# - "${PROD_SERVER}:${PROD_IP}"
|
||||||
|
|
||||||
networks:
|
# networks:
|
||||||
- default
|
# - default
|
||||||
- logisticsNetwork
|
# - logisticsNetwork
|
||||||
- mlan1
|
# #- mlan1
|
||||||
networks:
|
# networks:
|
||||||
logisticsNetwork:
|
# logisticsNetwork:
|
||||||
driver: macvlan
|
# driver: macvlan
|
||||||
driver_opts:
|
# driver_opts:
|
||||||
parent: eth0
|
# parent: eth0
|
||||||
ipam:
|
# ipam:
|
||||||
config:
|
# config:
|
||||||
- subnet: ${LOGISTICS_NETWORK}
|
# - subnet: ${LOGISTICS_NETWORK}
|
||||||
gateway: ${LOGISTICS_GATEWAY}
|
# gateway: ${LOGISTICS_GATEWAY}
|
||||||
|
|
||||||
mlan1:
|
# mlan1:
|
||||||
driver: macvlan
|
# driver: macvlan
|
||||||
driver_opts:
|
# driver_opts:
|
||||||
parent: eth0
|
# parent: eth0
|
||||||
ipam:
|
# ipam:
|
||||||
config:
|
# config:
|
||||||
- subnet: ${MLAN1_NETWORK}
|
# - subnet: ${MLAN1_NETWORK}
|
||||||
gateway: ${MLAN1_GATEWAY}
|
# gateway: ${MLAN1_GATEWAY}
|
||||||
|
|||||||
Reference in New Issue
Block a user