Skip to content

Commit 7a90bb0

Browse files
committed
Add docker builds
Signed-off-by: Jens Reidel <[email protected]>
1 parent 9fa5b42 commit 7a90bb0

File tree

5 files changed

+102
-46
lines changed

5 files changed

+102
-46
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Adjust this to your main branch
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Build and push Docker image
27+
uses: docker/build-push-action@v5
28+
with:
29+
context: .
30+
push: true
31+
build-args: |
32+
VITE_API_HOSTNAME=/
33+
tags: |
34+
ghcr.io/${{ github.repository }}:latest
35+
ghcr.io/${{ github.repository }}:${{ github.sha }}

.github/workflows/check.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM docker.io/library/alpine:edge AS builder
2+
ARG VITE_API_HOSTNAME
3+
4+
RUN apk add --no-cache nodejs-current npm
5+
6+
WORKDIR /src
7+
COPY . .
8+
9+
RUN echo "VITE_API_HOSTNAME=${VITE_API_HOSTNAME}" > .env.local && \
10+
npm i && \
11+
npm run build
12+
13+
FROM docker.io/library/nginx:alpine
14+
15+
COPY --from=builder /src/dist /dist
16+
COPY nginx.conf /etc/nginx/nginx.conf

nginx.conf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
user nginx;
2+
worker_processes auto;
3+
4+
error_log /dev/stderr; # Redirect error logs to stderr
5+
pid /var/run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
12+
http {
13+
include /etc/nginx/mime.types;
14+
default_type application/octet-stream;
15+
16+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
17+
'$status $body_bytes_sent "$http_referer" '
18+
'"$http_user_agent" "$http_x_forwarded_for"';
19+
20+
access_log /dev/stdout main; # Redirect access logs to stdout
21+
22+
sendfile on;
23+
24+
keepalive_timeout 65;
25+
26+
server {
27+
listen 80 default;
28+
real_ip_header X-Real-IP;
29+
real_ip_recursive on;
30+
set_real_ip_from 0.0.0.0/0;
31+
32+
root /dist/;
33+
index index.html index.htm;
34+
gzip on;
35+
gzip_disable "msie6";
36+
gzip_vary on;
37+
gzip_proxied any;
38+
gzip_comp_level 6;
39+
gzip_buffers 15 8k;
40+
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
41+
42+
location / {
43+
try_files $uri $uri/ /index.html;
44+
}
45+
46+
location ~* \.(?:css|js|png)$ {
47+
expires 1d;
48+
add_header Cache-Control "public";
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)