Skip to content

Commit 079f147

Browse files
authored
Merge pull request #6 from ChrSchu90/bugfix/BaseImage
- Fixed used base image and simplified gost download - Update workflow for better CI coverage - Update README
2 parents 50e4659 + 6399351 commit 079f147

4 files changed

Lines changed: 43 additions & 39 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
NET_PUBLISH_ARGS: "--verbosity normal --configuration Release -p:DebugType=embedded -p:PublishSingleFile=true --self-contained"
2424
DOCKER_REGISTRY: ghcr.io
2525
DOCKER_IMAGE_NAME: ${{ github.repository_owner }}/mullvad-proxy-gateway
26-
DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64/v8
26+
DOCKER_PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
2727

2828
jobs:
2929
build:
@@ -61,38 +61,43 @@ jobs:
6161
run: dotnet test ${{ env.NET_SOLUTION }} --verbosity normal --no-restore --no-build --configuration Release
6262

6363
- name: .NET Publish amd64
64-
if: ${{ steps.tagver.outputs.is_valid == 'true' }}
65-
run: dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-x64 ${{ env.NET_PUBLISH_ARGS }} -p:Version=${{ steps.tagver.outputs.version }} -o ${{ env.NET_PUBLISH_DIR }}linux/amd64
64+
run: |
65+
if [ -n "${{ steps.tagver.outputs.version }}" ]; then
66+
dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-x64 ${{ env.NET_PUBLISH_ARGS }} -p:Version=${{ steps.tagver.outputs.version }} -o ${{ env.NET_PUBLISH_DIR }}linux/amd64
67+
else
68+
dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-x64 ${{ env.NET_PUBLISH_ARGS }} -o ${{ env.NET_PUBLISH_DIR }}linux/amd64
69+
fi
70+
71+
- name: .NET Publish arm64
72+
run: |
73+
if [ -n "${{ steps.tagver.outputs.version }}" ]; then
74+
dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-arm64 ${{ env.NET_PUBLISH_ARGS }} -p:Version=${{ steps.tagver.outputs.version }} -o ${{ env.NET_PUBLISH_DIR }}linux/arm64
75+
else
76+
dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-arm64 ${{ env.NET_PUBLISH_ARGS }} -o ${{ env.NET_PUBLISH_DIR }}linux/arm64
77+
fi
6678
6779
- name: .NET Publish armv7
68-
if: ${{ steps.tagver.outputs.is_valid == 'true' }}
69-
run: dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-arm ${{ env.NET_PUBLISH_ARGS }} -p:Version=${{ steps.tagver.outputs.version }} -o ${{ env.NET_PUBLISH_DIR }}linux/arm/v7
70-
71-
- name: .NET Publish armv8
72-
if: ${{ steps.tagver.outputs.is_valid == 'true' }}
73-
run: dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-arm64 ${{ env.NET_PUBLISH_ARGS }} -p:Version=${{ steps.tagver.outputs.version }} -o ${{ env.NET_PUBLISH_DIR }}linux/arm64/v8
80+
run: |
81+
if [ -n "${{ steps.tagver.outputs.version }}" ]; then
82+
dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-arm ${{ env.NET_PUBLISH_ARGS }} -p:Version=${{ steps.tagver.outputs.version }} -o ${{ env.NET_PUBLISH_DIR }}linux/armv7
83+
else
84+
dotnet publish ${{ env.NET_PROJECT }} -r linux-musl-arm ${{ env.NET_PUBLISH_ARGS }} -o ${{ env.NET_PUBLISH_DIR }}linux/armv7
85+
fi
7486
7587
- name: Docker QEMU Setup
76-
if: ${{ steps.tagver.outputs.is_valid == 'true' }}
7788
uses: docker/setup-qemu-action@v4
78-
id: dockerqemu
7989

8090
- name: Docker Buildx Setup
81-
if: ${{ steps.dockerqemu.outcome == 'success' }}
8291
uses: docker/setup-buildx-action@v4
83-
id: dockersetup
8492

8593
- name: Docker Login
8694
uses: docker/login-action@v4
87-
if: ${{ steps.dockersetup.outcome == 'success' }}
88-
id: dockerlogin
8995
with:
9096
registry: ${{ env.DOCKER_REGISTRY }}
9197
username: ${{ github.repository_owner }}
9298
password: ${{ secrets.GITHUB_TOKEN }}
9399

94100
- name: Docker tags/labels
95-
if: ${{ steps.dockerlogin.outcome == 'success' }}
96101
uses: docker/metadata-action@v6
97102
id: dockermeta
98103
with:
@@ -116,6 +121,8 @@ jobs:
116121
type=raw,value=${{ steps.tagver.outputs.version }}-preview,enable=${{ steps.tagver.outputs.is_prerelease == 'true' }}
117122
# Specific preview build (fully pinned)
118123
type=raw,value=${{ steps.tagver.outputs.version }}-${{ steps.tagver.outputs.suffix }},enable=${{ steps.tagver.outputs.is_prerelease == 'true' }}
124+
# Test build
125+
type=raw,value=ci,enable=${{ steps.tagver.outputs.is_valid != 'true' }}
119126
120127
- name: Docker build/push
121128
if: ${{ steps.dockermeta.outcome == 'success' }}
@@ -132,7 +139,7 @@ jobs:
132139

133140
- name: Create Release
134141
uses: softprops/action-gh-release@v2
135-
if: ${{ steps.dockerbuild.outcome == 'success' }}
142+
if: ${{ steps.tagver.outputs.is_valid == 'true' }}
136143
with:
137144
tag_name: ${{ steps.tagver.outputs.version_tag }}
138145
prerelease: ${{ steps.tagver.outputs.is_prerelease == 'true' }}

Dockerfile

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
FROM --platform=$BUILDPLATFORM alpine:3.23
2-
ARG BUILDPLATFORM=linux/amd64
1+
FROM alpine:3.23
2+
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
ARG TARGETVARIANT
36
ARG GOST_VERSION=3.2.6
47

58
# Install required tools, dotnet dependencies and wireguard dependencies + fixes
6-
RUN apk add --no-cache curl \
9+
RUN apk add --no-cache curl grep \
710
icu-libs icu-data-full \
811
iproute2 iptables ip6tables openresolv wireguard-tools && \
912
echo "wireguard" >> /etc/modules && \
13+
rm -rf /etc/wireguard && \
14+
ln -s /config/wg_confs /etc/wireguard && \
1015
sed -i 's|\[\[ $proto == -4 \]\] && cmd sysctl -q net\.ipv4\.conf\.all\.src_valid_mark=1|[[ $proto == -4 ]] \&\& [[ $(sysctl -n net.ipv4.conf.all.src_valid_mark) != 1 ]] \&\& cmd sysctl -q net.ipv4.conf.all.src_valid_mark=1|' /usr/bin/wg-quick && \
1116
rm -rf /tmp/* /var/tmp/* /var/cache/distfiles/*
1217

1318
# Download and add GOST binary (https://github.com/go-gost/gost) for socks5 proxy server
14-
RUN set -eux; \
15-
apk add --no-cache --virtual .fetch-deps wget tar; \
16-
case "${BUILDPLATFORM}" in \
17-
"linux/amd64") GOST_ARCH="linux_amd64" ;; \
18-
"linux/arm/v7") GOST_ARCH="linux_armv7" ;; \
19-
"linux/arm64/v8") GOST_ARCH="linux_arm64" ;; \
20-
"") echo "BUILDPLATFORM is empty — are you using buildx / BuildKit?"; exit 1 ;; \
21-
*) echo "Unsupported BUILDPLATFORM: ${BUILDPLATFORM}"; exit 1 ;; \
22-
esac; \
23-
wget -qO /tmp/gost.tar.gz "https://github.com/go-gost/gost/releases/download/v${GOST_VERSION}/gost_${GOST_VERSION}_${GOST_ARCH}.tar.gz"; \
24-
tar -xzf /tmp/gost.tar.gz -C /; \
25-
chmod a+x /gost; \
26-
apk del .fetch-deps; \
27-
rm -rf /tmp/* /var/tmp/* /var/cache/distfiles/*;
19+
RUN apk add --no-cache --virtual .fetch-deps wget tar && \
20+
wget -qO /tmp/gost.tar.gz "https://github.com/go-gost/gost/releases/download/v${GOST_VERSION}/gost_${GOST_VERSION}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.gz" && \
21+
tar -xzf /tmp/gost.tar.gz -C / && \
22+
chmod a+x /gost && \
23+
apk del .fetch-deps && \
24+
rm -rf /tmp/* /var/tmp/* /var/cache/distfiles/*
2825

2926
# Add project binaries
3027
COPY --chmod=755 run.sh /run.sh
31-
COPY --chmod=755 GostGen/publish/${BUILDPLATFORM} .
28+
COPY --chmod=755 GostGen/publish/${TARGETOS}/${TARGETARCH}${TARGETVARIANT} .
3229

3330
HEALTHCHECK --interval=30s --timeout=30s --retries=5 --start-period=30s CMD \
3431
sh -c "curl -fs https://am.i.mullvad.net/json | grep -q '\"mullvad_exit_ip\":true'"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ and download multiple configuration files (for example, for Germany – Frankfur
7878

7979
Place the downloaded configuration files in the `data` volume.
8080
Note that the file names determine the order in which the connections are attempted,
81-
so name them accordingly (e.g., 01-de-fra-wg-001.conf, 02-de-fra-wg-002.conf, 03-de-fra-wg-003.conf, etc.).
81+
so name them accordingly (e.g., 01-de-fra.conf, 02-de-fra.conf, 03-de-fra.conf, etc.).
8282

8383
You may also include configurations for different locations. The first successfully working configuration will be used.
8484

debug.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
cd "$(dirname "$0")"
3+
cd "$(dirname "$0")" || exit
44

55
DOCKER_FILE="Dockerfile"
66
IMAGE_NAME="mullvad-proxy-gateway:dev"
@@ -9,8 +9,8 @@ NET_BUILD_ARGS="-p:DebugType=embedded -p:PublishSingleFile=true -p:Version=0.0.1
99
GOST_VERSION="3.2.6"
1010

1111
dotnet publish ${NET_PROJECT} -r linux-musl-x64 ${NET_BUILD_ARGS} -o ./GostGen/publish/linux/amd64 && \
12-
dotnet publish ${NET_PROJECT} -r linux-musl-arm ${NET_BUILD_ARGS} -o ./GostGen/publish/linux/arm/v7 && \
13-
dotnet publish ${NET_PROJECT} -r linux-musl-arm64 ${NET_BUILD_ARGS} -o ./GostGen/publish/linux/arm64/v8 && \
12+
dotnet publish ${NET_PROJECT} -r linux-musl-arm64 ${NET_BUILD_ARGS} -o ./GostGen/publish/linux/arm64 && \
13+
dotnet publish ${NET_PROJECT} -r linux-musl-arm ${NET_BUILD_ARGS} -o ./GostGen/publish/linux/armv7 && \
1414
docker buildx build --progress=plain --rm --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --build-arg GOST_VERSION=${GOST_VERSION} -f ${DOCKER_FILE} -t ${IMAGE_NAME} . && \
1515
docker volume create mullvadproxygateway_data && \
1616
docker run --rm -it -v mullvadproxygateway_data:/data -p 1080:1080 -p 9100:9100 -p 2000-3000:2000-3000 --cap-add NET_ADMIN --sysctl net.ipv4.conf.all.src_valid_mark=1 ${IMAGE_NAME}

0 commit comments

Comments
 (0)