Skip to content

Commit 28f7cd8

Browse files
committed
Docker stuff
1 parent a7d9e8a commit 28f7cd8

4 files changed

Lines changed: 102 additions & 27 deletions

File tree

.github/workflows/docker.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build Docker Images
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
env:
11+
IMAGE_NAME: wg-obfuscator
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
strategy:
21+
matrix:
22+
platform: [amd64, arm64, arm/v7, arm/v6, 386, ppc64le, s390x]
23+
fail-fast: false
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Prepare tar filename
33+
id: prep
34+
run: |
35+
SAFE_NAME="${{ env.IMAGE_NAME }}-${{ matrix.platform }}"
36+
SAFE_NAME="${SAFE_NAME//\//-}"
37+
echo "tar_name=$SAFE_NAME.tar" >> $GITHUB_OUTPUT
38+
39+
- name: Build per-arch image and export as tar
40+
uses: docker/build-push-action@v5
41+
with:
42+
push: false
43+
tags: ${{ env.IMAGE_NAME }}:${{ matrix.platform }}
44+
platforms: ${{ matrix.platform }}
45+
outputs: type=docker,dest=${{ steps.prep.outputs.tar_name }}
46+
context: .
47+
48+
- name: Upload image tar
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: ${{ steps.prep.outputs.tar_name }}
52+
path: ${{ steps.prep.outputs.tar_name }}

.github/workflows/publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build & Publish Multiarch Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
IMAGE_NAME: wg-obfuscator
8+
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x
9+
10+
jobs:
11+
build-and-push:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
strategy:
18+
fail-fast: false
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKERHUB_USERNAME }}
31+
password: ${{ secrets.DOCKERHUB_TOKEN }}
32+
33+
- name: Build and push multiarch image
34+
uses: docker/build-push-action@v5
35+
with:
36+
push: true
37+
tags: clustermeerkat/${{ env.IMAGE_NAME }}:latest
38+
platforms: ${{ env.PLATFORMS }}
39+
context: .

Dockerfile

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
# Stage 1: Build
2-
FROM ubuntu:latest AS builder
2+
FROM alpine:latest AS build
3+
WORKDIR /src
34

4-
# Install necessary build tools and dependencies
5-
RUN apt-get update && \
6-
apt-get install -y build-essential sudo git systemctl
5+
RUN apk add --no-cache build-base argp-standalone
76

8-
# Add the current project to the container
9-
COPY . /usr/src/app
7+
COPY wg-obfuscator.c wg-obfuscator.h Makefile ./
108

11-
# Set the working directory
12-
WORKDIR /usr/src/app
13-
14-
# Build the project using make
15-
RUN make
16-
17-
# Install the built project into the /install directory
18-
RUN mkdir /install && \
19-
make install
9+
RUN make clean && make CC="gcc -static" LDFLAGS="-largp"
2010

2111
# Stage 2: Runtime
22-
FROM ubuntu:latest
23-
24-
# Copy installed files from builder stage
25-
COPY --from=builder /usr/bin/wg-obfuscator /usr/bin/wg-obfuscator
26-
COPY --from=builder /etc/wg-obfuscator.conf /etc/wg-obfuscator.conf
27-
28-
# Ensure necessary permissions
29-
RUN chmod +x /usr/bin/wg-obfuscator
30-
31-
# Command to start the service
32-
CMD ["wg-obfuscator", "-c", "/etc/wg-obfuscator.conf"]
12+
FROM alpine:latest
13+
WORKDIR /app
14+
COPY --from=build /src/wg-obfuscator ./wg-obfuscator
15+
COPY wg-obfuscator.conf /etc/wg-obfuscator/wg-obfuscator.conf
16+
ENTRYPOINT ["./wg-obfuscator", "-c", "/etc/wg-obfuscator/wg-obfuscator.conf"]

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
context: .
77
dockerfile: Dockerfile
88
volumes:
9-
- ./.wg-obfuscator.conf:/etc/wg-obfuscator.conf
9+
- ./.wg-obfuscator.conf:/etc/wg-obfuscator/wg-obfuscator.conf
1010
ports:
1111
- "13255:13255/udp"
1212
- "13255:13255/tcp"

0 commit comments

Comments
 (0)