Skip to content

Commit bdfc17a

Browse files
committed
Add Dockerfile and CI workflow for building and publishing Docker image: Set up a Dockerfile for Hugo builds with necessary dependencies and create a GitHub Actions workflow to automate the build and push process to the GitHub Container Registry.
1 parent 48c131e commit bdfc17a

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# .github/workflows/docker-image.yml
2+
name: Build and Publish Docker Image
3+
4+
on:
5+
push:
6+
branches:
7+
- trunk
8+
paths:
9+
- "Dockerfile"
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Log in to the GitHub Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ghcr.io/${{ github.repository }}
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v6
37+
with:
38+
context: .
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Dockerfile for Doula Cooperative Hugo builds
2+
# Start from a stable, minimal base image
3+
FROM ubuntu:22.04
4+
5+
# Avoid prompts from apt
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
8+
# Set versions for our tools as arguments
9+
ARG HUGO_VERSION=0.128.2
10+
ARG DART_SASS_VERSION=1.77.8
11+
12+
# 1. Install base dependencies
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
curl \
15+
wget \
16+
ca-certificates \
17+
unzip \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# 2. Install Bun
21+
RUN curl -fsSL https://bun.sh/install | bash
22+
ENV PATH="/root/.bun/bin:$PATH"
23+
24+
# 3. Install Hugo (Extended Version)
25+
RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" \
26+
&& apt-get install -y ./hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
27+
&& rm hugo_extended_${HUGO_VERSION}_linux-amd64.deb
28+
29+
# 4. Install Dart Sass
30+
RUN wget "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" \
31+
&& tar -xzf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" \
32+
&& mv dart-sass /usr/local/share/ \
33+
&& ln -s /usr/local/share/dart-sass/sass /usr/local/bin/sass \
34+
&& rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
35+
36+
# 5. Verify installations
37+
RUN echo "Bun version: $(bun --version)"
38+
RUN echo "Hugo version: $(hugo version)"
39+
RUN echo "Sass version: $(sass --version)"
40+
41+
# Set the working directory for when the container starts
42+
WORKDIR /workspace

0 commit comments

Comments
 (0)