feat: add docker build and push

This commit is contained in:
Lars Hampe 2024-08-17 17:28:23 +02:00
parent e23dcd1835
commit f3a746ea41
5 changed files with 92 additions and 2 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
.DS_Store
node_modules
dist

View File

@ -0,0 +1,42 @@
name: Build and Push Docker Image
run-name: ${{ gitea.actor }}
on:
push:
branches:
- main
jobs:
BuildAndPush:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set docker chmod (temp solution)
run: sudo chmod 666 /var/run/docker.sock
- name: Docker - Login
uses: docker/login-action@v1
with:
registry: git.hashdot.co
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Use Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.21
- name: Install dependencies
run: bun install
- name: Build
run: bun run build
- name: Build Docker Image
run: bun run docker:build
- name: Push Docker Image
run: bun run docker:push

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM oven/bun:1 as build
WORKDIR /app
COPY . .
RUN bun install
RUN bun run build
FROM nginx:alpine AS runtime
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 8080

31
nginx/nginx.conf Normal file
View File

@ -0,0 +1,31 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
internal;
}
location / {
try_files $uri $uri/index.html =404;
}
}
}

View File

@ -7,7 +7,9 @@
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"docker:build": "docker build -t git.hashdot.co/hashdot/website .",
"docker:push": "docker push git.hashdot.co/hashdot/website"
},
"dependencies": {
"@astrojs/check": "^0.9.2",