mirror of
https://github.com/MrUnknownDE/unknownbin.git
synced 2026-04-18 13:53:44 +02:00
feat: Add Docker and GitHub Actions for CI/CD
This commit is contained in:
48
Dockerfile
Normal file
48
Dockerfile
Normal file
@@ -0,0 +1,48 @@
|
||||
# --- Base Stage ---
|
||||
# Use a lightweight and secure Node.js base image
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy package files and install dependencies
|
||||
# This leverages Docker's layer caching
|
||||
COPY package*.json ./
|
||||
RUN npm install --only=production
|
||||
|
||||
|
||||
# --- Build Stage ---
|
||||
# This stage builds the static assets
|
||||
FROM base AS build
|
||||
|
||||
# Install all dependencies (including devDependencies) to run the build script
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
# Copy the rest of the application source code
|
||||
COPY . .
|
||||
|
||||
# Run the build script to minify CSS and JS
|
||||
RUN npm run build
|
||||
|
||||
|
||||
# --- Production Stage ---
|
||||
# This is the final, lean image that will be run
|
||||
FROM base AS production
|
||||
|
||||
# Set a non-root user for security
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
USER appuser
|
||||
|
||||
# Copy only the necessary files from the previous stages
|
||||
COPY --from=build /usr/src/app/node_modules ./node_modules
|
||||
COPY --from=build /usr/src/app/static ./static
|
||||
COPY --from=build /usr/src/app/lib ./lib
|
||||
COPY --from=build /usr/src/app/server.js .
|
||||
COPY --from=build /usr/src/app/config.json .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
||||
# The command to start the application
|
||||
CMD [ "node", "server.js" ]
|
||||
Reference in New Issue
Block a user