Skip to content

Commit 7f9fae4

Browse files
Merge pull request #143 from fclairamb/feature/docker-multiarch
Docker multi arch fix
2 parents 47df178 + 1b597c3 commit 7f9fae4

File tree

3 files changed

+66
-28
lines changed

3 files changed

+66
-28
lines changed

.github/workflows/docker-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 1
1212
services:
1313
ftpserver:
14-
image: ftpserver/ftpserver
14+
image: fclairamb/ftpserver
1515
ports:
1616
- 2121-2130:2121-2130
1717

.github/workflows/docker.yml

+50-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,54 @@
1-
name: Docker Image
1+
name: Docker image v2
22

33
on:
4-
push:
5-
release:
6-
types:
7-
- created
4+
push:
5+
branches:
6+
- "**"
7+
tags:
8+
- "v*.*.*"
9+
pull_request:
810

911
jobs:
10-
create-docker-image:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v2
14-
15-
- name: Setup go
16-
uses: actions/setup-go@v2
17-
with:
18-
go-version: 1.15
19-
20-
- name: Build
21-
run: CGO_ENABLED=0 go build
22-
23-
- name: Publish to Registry
24-
uses: elgohr/Publish-Docker-Github-Action@master
25-
with:
26-
name: ftpserver/ftpserver
27-
username: ftpserver
28-
password: ${{ secrets.DOCKER_PASSWORD }}
29-
tag_semver: true
12+
multi-registries:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Docker meta
18+
id: docker_meta
19+
uses: crazy-max/ghaction-docker-meta@v1
20+
with:
21+
images: fclairamb/ftpserver
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v1
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v1
26+
- name: Cache Docker layers
27+
uses: actions/cache@v2
28+
with:
29+
path: /tmp/.buildx-cache
30+
key: ${{ runner.os }}-buildx-${{ github.sha }}
31+
restore-keys: |
32+
${{ runner.os }}-buildx-
33+
- name: Login to DockerHub
34+
uses: docker/login-action@v1
35+
with:
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.DOCKERHUB_TOKEN }}
38+
- name: Login to GitHub Container Registry
39+
uses: docker/login-action@v1
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.repository_owner }}
43+
password: ${{ secrets.CR_PAT }}
44+
- name: Build and push
45+
uses: docker/build-push-action@v2
46+
with:
47+
context: .
48+
file: ./Dockerfile
49+
platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64
50+
push: true
51+
tags: ${{ steps.docker_meta.outputs.tags }}
52+
labels: ${{ steps.docker_meta.outputs.labels }}
53+
cache-from: type=local,src=/tmp/.buildx-cache
54+
cache-to: type=local,dest=/tmp/.buildx-cache

Dockerfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# Should be started with:
2-
# docker run -ti -p 2121-2130:2121-2130 ftpserver/ftpserver
2+
# docker run -ti -p 2121-2130:2121-2130 fclairamb/ftpserver
3+
4+
# Preparing the build environment
5+
FROM golang:1.15-alpine AS builder
6+
ENV GOFLAGS="-mod=readonly"
7+
RUN apk add --update --no-cache bash ca-certificates curl git
8+
RUN mkdir -p /workspace
9+
WORKDIR /workspace
10+
11+
# Building
12+
COPY . .
13+
RUN go build -v -o ftpserver
14+
15+
# Preparing the final image
316
FROM alpine:3.12.1
417
EXPOSE 2121-2130
5-
COPY ftpserver /bin/ftpserver
18+
COPY --from=builder /workspace/ftpserver /bin/ftpserver
619
ENTRYPOINT [ "/bin/ftpserver" ]

0 commit comments

Comments
 (0)