feat: prepare build and deploy to deploy docker image

This commit is contained in:
JasterV 2026-04-26 17:49:47 +02:00
parent 8548c1a00d
commit 845aea809c
4 changed files with 83 additions and 24 deletions

3
.dockerignore Normal file
View file

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

View file

@ -6,27 +6,13 @@ depends_on:
- ci
steps:
build:
image: oven/bun:debian
environment:
FTP_HOST:
from_secret: FTP_HOST
FTP_USERNAME:
from_secret: FTP_USERNAME
FTP_PASSWORD:
from_secret: FTP_PASSWORD
commands:
- apt-get update && apt-get install -y curl make
- curl -fsSL https://d2lang.com/install.sh | sh -s --
- bun install
- bun run build
# Deploy using Sam Kirkland's script via Bun (ultra fast)
# We use 'bunx' to run the package without permanently installing it
- |
bunx @samkirkland/ftp-deploy \
--server "$FTP_HOST" \
--username "$FTP_USERNAME" \
--password "$FTP_PASSWORD" \
--local-dir "dist/" \
--server-dir "/" \
--log-level "standard"
build-latest-container:
image: woodpeckerci/plugin-docker-buildx:6.0.3
settings:
registry: codeberg.org
username: ${CI_REPO_OWNER}
password:
from_secret: CONTAINER_REGISTRY_TOKEN
repo: codeberg.org/jasterv/blog
dockerfile: "Dockerfile"
tags: sha-${CI_COMMIT_SHA},latest

39
Dockerfile Normal file
View file

@ -0,0 +1,39 @@
# --- Build ---
FROM oven/bun:latest AS build
WORKDIR /app
# Copy lockfile and package.json to cache dependencies
COPY package.json bun.lockb ./
# Install dependencies needed for the D2 installer
# oven/bun:latest is Debian-based, so we use apt-get
RUN apt-get update && apt-get install -y \
curl \
build-essential \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install D2 and VERIFY immediately
# Adding 'd2 --version' ensures the build stops if the install failed
RUN curl -fsSL https://d2lang.com/install.sh | sh -s -- && d2 --version
# Install dependencies
RUN bun install --frozen-lockfile
# Copy the rest of your source code
COPY . .
# Build the static site
RUN bun run build
# --- Runtime ---
FROM nginx:stable-alpine AS runtime
# Copy the custom nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy the static files from the build stage
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 8080

31
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;
}
}
}