Skip to content

Commit ab4a521

Browse files
author
octeep
authored
Merge pull request #45 from jordemort/distroless-docker
Redo Dockerfile
2 parents 0b72e1d + b592741 commit ab4a521

6 files changed

Lines changed: 96 additions & 36 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.dockerignore
2+
.github
3+
.gitignore
4+
Dockerfile
5+
LICENSE
6+
README.md

.github/workflows/container.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build container
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
# Allow for manually running
9+
workflow_dispatch:
10+
inputs:
11+
container_tag:
12+
description: Tag for container
13+
default: "latest"
14+
required: true
15+
16+
permissions:
17+
packages: write
18+
19+
jobs:
20+
container:
21+
runs-on: ubuntu-20.04
22+
23+
env:
24+
CONTAINER_NAME: ghcr.io/${{ github.repository }}
25+
BUILD_PLATFORMS: linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x
26+
RAW_CONTAINER_TAG: ${{ github.event.inputs.container_tag || github.event.pull_request.head.ref || 'latest' }}
27+
RAW_REF_NAME: ${{ github.event.pull_request.head.ref || github.ref }}
28+
29+
steps:
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v2
32+
33+
- name: Set up Docker Buildx
34+
id: buildx
35+
uses: docker/setup-buildx-action@v2.0.0
36+
37+
- name: Login to GitHub Container Registry
38+
uses: docker/login-action@v2
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- uses: actions/checkout@v3
45+
with:
46+
submodules: recursive
47+
48+
# Needed for buildx gha cache to work
49+
- name: Expose GitHub Runtime
50+
uses: crazy-max/ghaction-github-runtime@v2
51+
52+
- name: Build container
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
CONTAINER_TAG=$(echo "$RAW_CONTAINER_TAG" | sed 's/[^a-zA-Z0-9]\+/-/')
57+
REF_NAME=$(echo "$RAW_REF_NAME" | sed -r 's#^refs/(heads|tags)/##')
58+
59+
docker buildx build \
60+
--platform "$BUILD_PLATFORMS" \
61+
--tag "$CONTAINER_NAME:$CONTAINER_TAG" \
62+
--label "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
63+
--label "org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}" \
64+
--label "org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/packages" \
65+
--label "org.opencontainers.image.ref.name=$REF_NAME" \
66+
--label "org.opencontainers.image.revision=${{ github.sha }}" \
67+
--label "org.opencontainers.image.vendor=${{ github.repository_owner }}" \
68+
--label "org.opencontainers.image.created=$(date -u --rfc-3339=seconds)" \
69+
--cache-from type=gha \
70+
--cache-to type=gha,mode=max \
71+
--pull ${{ github.event_name == 'push' && '--push' || '' }} .

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Start by building the application.
2+
FROM golang:1.18 as build
3+
4+
WORKDIR /usr/src/wireproxy
5+
COPY . .
6+
7+
RUN CGO_ENABLED=0 go build ./cmd/wireproxy
8+
9+
# Now copy it into our base image.
10+
FROM gcr.io/distroless/static-debian11:nonroot
11+
COPY --from=build /usr/src/wireproxy/wireproxy /usr/bin/wireproxy
12+
13+
VOLUME [ "/etc/wireproxy"]
14+
ENTRYPOINT [ "/usr/bin/wireproxy" ]
15+
CMD [ "--config", "/etc/wireproxy/config" ]
16+
17+
LABEL org.opencontainers.image.title wireproxy
18+
LABEL org.opencontainers.image.description "Wireguard client that exposes itself as a socks5 proxy"
19+
LABEL org.opencontainers.image.licenses ISC

docker/Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker/Makefile

Lines changed: 0 additions & 10 deletions
This file was deleted.

docker/config

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)