diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a644016 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules/ +dist/ +data/ +.git/ +.env +.env.* +!.env.example +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f2aa88e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# Build stage +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install all dependencies (including dev dependencies for building) +RUN npm ci + +# Copy source code +COPY . . + +# Build the Vite SPA +RUN npm run build + +# Production stage +FROM node:18-alpine + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install only production dependencies +RUN npm ci --omit=dev + +# Copy server files +COPY server.mjs ./ +COPY server/ ./server/ + +# Copy built frontend +COPY --from=builder /app/dist ./dist + +# Create data directory for runtime storage +RUN mkdir -p data && chown -R node:node data + +# Switch to non-root user +USER node + +# Expose the API port +EXPOSE 3000 + +# Start the server +CMD ["node", "server.mjs"] diff --git a/README.md b/README.md index 6edf7c7..23e3e2e 100644 --- a/README.md +++ b/README.md @@ -82,10 +82,9 @@ Then put a reverse proxy (Caddy, nginx, …) in front of `localhost:3000`. ### Deployment -This repo contains **only the app** — the Dockerfile, docker-compose, -Caddy fragment, and `.env` generation script for the Jannik-Cloud -service live alongside the rest of the Jannik-Cloud services. To -deploy, copy them into a new `services/melodymuse/` directory there. +This app follows a Docker-First workflow. The Docker image is built directly from this repository and pushed to the Gitea Container Registry (`git.orfel.de/jannik/melodymuse`). + +The production server (Jannik-Cloud) simply pulls the pre-built image and runs it. ---