From 7fc6859f7e4d6ee89808106dd329a3c8508e1a46 Mon Sep 17 00:00:00 2001 From: Weetile Date: Mon, 14 Oct 2024 17:49:17 +0100 Subject: [PATCH] github ci/cd --- .github/workflows/docker-publish.yml | 32 ++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++++++ go.mod | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..64af4c4 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,32 @@ +name: Build and Publish Multi-Architecture Hugo Site + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push multi-platform image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/weetile.uk:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cb141b1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Step 1: Build the Hugo site +FROM klakegg/hugo:ext-alpine AS build-stage + +# Set the working directory inside the container +WORKDIR /app + +# Copy all files to the working directory +COPY . . + +# Build the Hugo site +RUN hugo --minify + +# Step 2: Use an Apache httpd image to serve the site +FROM httpd:2.4-alpine + +# Copy the public folder from the build stage to the Apache document root +COPY --from=build-stage /app/public/ /usr/local/apache2/htdocs/ + diff --git a/go.mod b/go.mod index 629561a..a708a1d 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/Weetile/weetile.uk -go 1.22.5 +go 1.23 require github.com/jpanther/lynx v1.4.0 // indirect