diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8d67a86 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.DS_Store +node_modules +dist diff --git a/.woodpecker/deploy.yml b/.woodpecker/deploy.yml index d12c1e5..4616bf2 100644 --- a/.woodpecker/deploy.yml +++ b/.woodpecker/deploy.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c13cd2a --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..e6dd94a --- /dev/null +++ b/nginx.conf @@ -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; + } + } +}