adds deployment scripts

This commit is contained in:
William Diakite 2025-07-22 17:23:13 -04:00
parent e4ee90d7cd
commit 0c2e34bb61
3 changed files with 50 additions and 9 deletions

View file

@ -0,0 +1,21 @@
name: Deploy SvelteKit
on:
push:
branches:
- main
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Deploy with Docker
run: |
docker compose down
docker compose build
docker compose up -d

View file

@ -1,19 +1,28 @@
# Use a Node.js Alpine image for the builder stage
# Builder stage
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
# Install deps for build
COPY package*.json .
RUN npm ci
# Copy source and build
COPY . .
RUN npm run build
RUN npm prune --production
# Use another Node.js Alpine image for the final stage
# Final image
FROM node:22-alpine
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
# Copy only what's needed for runtime
COPY package.json ./
COPY --from=builder /app/build ./build/
COPY --from=builder /app/node_modules ./node_modules/
# Prune dev dependencies
RUN npm prune --production
EXPOSE 3000
ENV NODE_ENV=production
CMD [ "node", "build" ]
CMD ["node", "build"]

11
docker-compose.yml Normal file
View file

@ -0,0 +1,11 @@
version: "3.8"
services:
client:
build: .
container_name: client
restart: unless-stopped
ports:
- "3000:3000"
environment:
NODE_ENV: production