Skip to content

Commit c240893

Browse files
committed
fix arm64 build. Fix #189
1 parent fcae18d commit c240893

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

.github/workflows/docker-build.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313
- name: Extract branch name
14-
shell: bash
15-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
14+
run: echo "branch=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
1615
id: extract_branch
1716
- name: Set up QEMU
18-
uses: docker/setup-qemu-action@v1
17+
uses: docker/setup-qemu-action@v3
1918
- name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v1
19+
uses: docker/setup-buildx-action@v3
2120
- name: Login to DockerHub
22-
uses: docker/login-action@v1
21+
uses: docker/login-action@v3
2322
with:
2423
username: ${{ secrets.DOCKERHUB_USERNAME }}
2524
password: ${{ secrets.DOCKERHUB_TOKEN }}
2625
- name: Build and push
27-
uses: docker/build-push-action@v2
26+
uses: docker/build-push-action@v5
2827
with:
2928
tags: fundor333/hugo:${{ steps.extract_branch.outputs.branch }}
3029
context: .
31-
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
30+
platforms: linux/amd64,linux/arm64
3231
push: true
32+
pull: true

Dockerfile

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ LABEL maintainer "[email protected]"
44

55
# Download and install hugo
66
ENV HUGO_VERSION 0.118.2
7-
ENV HUGO_DIRECTORY hugo_extended_${HUGO_VERSION}_Linux-64bit
8-
ENV HUGO_BINARY ${HUGO_DIRECTORY}.tar.gz
97

108
# Installing Hugo and ca-certificates
119
RUN set -x &&\
12-
apk add gcompat &&\
13-
apk add libstdc++ &&\
14-
apk add --update wget ca-certificates &&\
10+
apk add --no-cache --update gcompat libstdc++ wget ca-certificates &&\
11+
case "$(uname -m)" in \
12+
x86_64) ARCH=amd64 ;; \
13+
aarch64) ARCH=arm64 ;; \
14+
*) echo "hugo official release only support amd64 and arm64 now"; exit 1 ;; \
15+
esac && \
16+
HUGO_DIRECTORY="hugo_extended_${HUGO_VERSION}_linux-${ARCH}" && \
17+
HUGO_BINARY="${HUGO_DIRECTORY}.tar.gz" && \
1518
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} &&\
1619
tar xzf ${HUGO_BINARY} &&\
17-
rm -r ${HUGO_BINARY} && \
20+
rm -fr ${HUGO_BINARY} README.md LICENSE && \
1821
mv hugo /usr/bin/hugo && \
19-
rm /var/cache/apk/* && \
2022
mkdir /usr/share/blog
2123

2224
WORKDIR /usr/share/blog

README.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ For my personal use I make smaller the image of _publysher_ because I use it in
1717

1818
The image is based on the following directory structure:
1919

20+
```txt
2021
.
2122
├── Dockerfile
2223
└── site
@@ -27,16 +28,21 @@ The image is based on the following directory structure:
2728
│   └── ...
2829
└── static
2930
└── ...
31+
```
3032

3133
In other words, your Hugo site resides in the `site` directory, and you have a simple Dockerfile:
3234

33-
FROM fundor333/hugo
35+
```dockerfile
36+
FROM fundor333/hugo
37+
```
3438

3539
## Building your site
3640

3741
Based on this structure, you can easily build an image for your site:
3842

39-
docker build -t my/image .
43+
```sh
44+
docker build -t my/image .
45+
```
4046

4147
Your site is automatically generated during this build.
4248

@@ -49,15 +55,21 @@ There are two options for using the image you generated:
4955

5056
Using your image as a stand-alone image is the easiest:
5157

52-
docker run -p 1313:1313 my/image
58+
```sh
59+
docker run -p 1313:1313 my/image
60+
```
5361

5462
This will automatically start `hugo server`, and your blog is now available on <http://localhost:1313>.
5563

5664
If you are using `boot2docker`, you need to adjust the base URL:
5765

58-
docker run -p 1313:1313 -e HUGO_BASE_URL=http://YOUR_DOCKER_IP:1313 my/image
66+
```sh
67+
docker run -p 1313:1313 -e HUGO_BASE_URL=http://YOUR_DOCKER_IP:1313 my/image
68+
```
5969

6070
The image is also suitable for use as a volume image for a web server, such as [nginx](https://registry.hub.docker.com/_/nginx/)
6171

62-
docker run -d -v /usr/share/nginx/html --name site-data my/image
63-
docker run -d --volumes-from site-data --name site-server -p 80:80 nginx
72+
```sh
73+
docker run -d -v /usr/share/nginx/html --name site-data my/image
74+
docker run -d --volumes-from site-data --name site-server -p 80:80 nginx
75+
```

0 commit comments

Comments
 (0)