Skip to content
This repository was archived by the owner on Dec 22, 2025. It is now read-only.

Commit 6e2da56

Browse files
Add Dockerfile and deploy.yml
1 parent 53f399e commit 6e2da56

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Deploy website
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
deploy-website:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v4
13+
14+
- name: Build Docker image
15+
run: docker build -t oliverschlueter/fancywebsite:latest .
16+
17+
18+
- name: Log in to Docker Hub
19+
uses: docker/login-action@v2
20+
with:
21+
username: ${{ secrets.DOCKER_USERNAME }}
22+
password: ${{ secrets.DOCKER_PASSWORD }}
23+
24+
- name: Push Docker image
25+
run: docker push oliverschlueter/fancywebsite:latest

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# ===== Stage 1: Build =====
2+
FROM node:18-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
# Install dependencies first for caching
7+
COPY package.json package-lock.json ./
8+
RUN npm ci
9+
10+
# Copy the rest of the project and build
11+
COPY . .
12+
RUN npm run build
13+
14+
# ===== Stage 2: Serve with Nginx =====
15+
FROM nginx:stable-alpine
16+
17+
# Remove default Nginx files
18+
RUN rm -rf /usr/share/nginx/html/*
19+
20+
# Copy built files from builder
21+
COPY --from=builder /app/dist /usr/share/nginx/html
22+
23+
# Copy custom nginx config (optional)
24+
# COPY nginx.conf /etc/nginx/conf.d/default.conf
25+
26+
EXPOSE 80
27+
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)