Skip to content

Commit 915bb33

Browse files
Merge pull request #218 from xavier-hernandez/214-add-docker-image-to-ghcr-using-githu
Add docker image to GHCR
2 parents 5f046f3 + 9e6f6b0 commit 915bb33

File tree

3 files changed

+52
-23
lines changed

3 files changed

+52
-23
lines changed

.github/workflows/docker-build.yml

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: branch build & push
22

33
on:
4-
#schedule:
5-
# - cron: '50 15 * * *' #Change this to when you want automatic builds
64
push:
75
paths-ignore:
86
- 'README.md'
@@ -17,75 +15,106 @@ jobs:
1715
build:
1816

1917
runs-on: ubuntu-latest
18+
2019
permissions:
2120
contents: read
2221
packages: write
23-
# This is used to complete the identity challenge
24-
# with sigstore/fulcio when running outside of PRs.
2522
id-token: write
2623

2724
steps:
2825
- name: Checkout repository
29-
uses: actions/checkout@v3
30-
26+
uses: actions/checkout@v4
27+
3128
- name: Set up QEMU
32-
uses: docker/setup-qemu-action@v2
33-
29+
uses: docker/setup-qemu-action@v3
30+
3431
- name: Setup Docker buildx
35-
uses: docker/setup-buildx-action@v2
32+
uses: docker/setup-buildx-action@v3
3633

3734
- name: Cache Docker layers
38-
uses: actions/cache@v3
35+
uses: actions/cache@v4
3936
with:
4037
path: /tmp/.buildx-cache
4138
key: ${{ runner.os }}-buildx-${{ github.sha }}
4239
restore-keys: |
4340
${{ runner.os }}-buildx-
4441
42+
# ------------------------------------------
43+
# Login to Docker Hub
44+
# ------------------------------------------
4545
- name: Login to Docker Hub
46-
uses: docker/login-action@v2
46+
uses: docker/login-action@v3
4747
with:
48+
registry: docker.io
4849
username: ${{ secrets.DOCKERHUB_USERNAME }}
4950
password: ${{ secrets.DOCKERHUB_TOKEN }}
50-
51+
52+
# ------------------------------------------
53+
# Login to GitHub Container Registry (GHCR)
54+
# ------------------------------------------
55+
- name: Login to GHCR
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ghcr.io
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
# ------------------------------------------------------
63+
# Build for MAIN → latest (Docker Hub + GHCR)
64+
# ------------------------------------------------------
5165
- name: Production Build and push
5266
if: ${{ github.ref == 'refs/heads/main' }}
53-
uses: docker/build-push-action@v3
67+
uses: docker/build-push-action@v5
5468
with:
5569
context: .
5670
push: true
57-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
5871
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
72+
tags: |
73+
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
74+
ghcr.io/${{ github.repository_owner }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
5975
cache-from: type=local,src=/tmp/.buildx-cache
6076
cache-to: type=local,dest=/tmp/.buildx-cache-new
6177

78+
# ------------------------------------------------------
79+
# Build for TAGS → versioned tags (Docker Hub + GHCR)
80+
# ------------------------------------------------------
6281
- name: Production Get Tag Name
6382
if: startsWith(github.ref, 'refs/tags/v')
6483
uses: little-core-labs/[email protected]
6584
id: tagName
6685

6786
- name: Production Tag Build and push
6887
if: startsWith(github.ref, 'refs/tags/v')
69-
uses: docker/build-push-action@v2
88+
uses: docker/build-push-action@v5
7089
with:
7190
context: .
7291
push: true
73-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.tagName.outputs.tag }}
7492
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
93+
tags: |
94+
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.tagName.outputs.tag }}
95+
ghcr.io/${{ github.repository_owner }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.tagName.outputs.tag }}
7596
cache-from: type=local,src=/tmp/.buildx-cache
76-
cache-to: type=local,dest=/tmp/.buildx-cache-new
97+
cache-to: type=local,dest=/tmp/.buildx-cache-new
7798

99+
# ------------------------------------------------------
100+
# Build for DEVELOP → develop tag (Docker Hub + GHCR)
101+
# ------------------------------------------------------
78102
- name: Development Build and push
79103
if: ${{ github.ref == 'refs/heads/develop' }}
80-
uses: docker/build-push-action@v2
104+
uses: docker/build-push-action@v5
81105
with:
82106
context: .
83107
push: true
84-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:develop
85108
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
109+
tags: |
110+
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:develop
111+
ghcr.io/${{ github.repository_owner }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:develop
86112
cache-from: type=local,src=/tmp/.buildx-cache
87113
cache-to: type=local,dest=/tmp/.buildx-cache-new
88114

115+
# ------------------------------------------
116+
# Move build cache
117+
# ------------------------------------------
89118
- name: Move cache
90119
run: |
91120
rm -rf /tmp/.buildx-cache

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.21.3 AS builder
1+
FROM alpine:latest AS builder
22

33
RUN apk add --no-cache \
44
build-base \
@@ -23,13 +23,13 @@ RUN make install
2323
WORKDIR /goaccess
2424
RUN cp /goaccess-temp/goaccess.tar.gz .
2525
RUN tar --strip-components=1 -xzvf goaccess.tar.gz
26-
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> \/ <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.37<\/span>/" /goaccess/resources/tpls.html
26+
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> \/ <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.38<\/span>/" /goaccess/resources/tpls.html
2727
RUN sed -i "s/bottom: 190px/bottom: 260px/" /goaccess/resources/css/app.css
2828
RUN ./configure --enable-utf8 --enable-geoip=mmdb --with-getline
2929
RUN make
3030
RUN make install
3131

32-
FROM alpine:3.21.3
32+
FROM alpine:latest
3333
RUN apk add --no-cache \
3434
bash \
3535
nginx \

resources/scripts/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source $(dirname "$0")/logs/ncsa_combined.sh
1010
source $(dirname "$0")/logs/nginx_access.sh
1111
source $(dirname "$0")/logs/caddy.sh
1212

13-
goan_version="GOAN v1.1.37"
13+
goan_version="GOAN v1.1.38"
1414
goan_log_path="/opt/log"
1515

1616
goaccess_ping_interval=15

0 commit comments

Comments
 (0)