Skip to content

Commit 5c0f575

Browse files
committed
Add Dockerfile and Github Actions workflow
1 parent 96bf8a8 commit 5c0f575

5 files changed

Lines changed: 85 additions & 0 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.o
2+
*.out
3+
out

.github/workflows/build.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ v* ]
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Login to GitHub Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.repository_owner }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Docker meta
32+
id: docker-meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: |
36+
ghcr.io/${{ github.repository }}
37+
tags: |
38+
type=sha,prefix=
39+
type=ref,event=tag
40+
41+
- name: Build and push
42+
uses: docker/build-push-action@v6
43+
with:
44+
push: true
45+
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x
46+
tags: ${{ steps.docker-meta.outputs.tags }}
47+
labels: ${{ steps.docker-meta.outputs.labels }}
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max
50+
outputs: type=local,dest=${{ github.workspace }}/out
51+
52+
- name: Get metadata for artifact naming
53+
id: meta
54+
run: |
55+
echo "commit-hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
56+
echo "repo-name=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT
57+
58+
- name: Upload built binaries
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: ${{ steps.meta.outputs.repo-name }}-${{ steps.meta.outputs.commit-hash }}
62+
path: ${{ github.workspace }}/out

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.o
22
*.out
3+
out
34

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM alpine AS builder
2+
RUN apk add --no-cache make gcc libc-dev
3+
WORKDIR /app
4+
ENV LDFLAGS=-static
5+
COPY . .
6+
RUN make
7+
8+
FROM scratch
9+
LABEL org.opencontainers.image.licenses=MIT
10+
COPY --from=builder /app/microsocks /
11+
ENTRYPOINT ["/microsocks"]

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ Supported SOCKS5 Features
6969
- IPv4, IPv6, DNS
7070
- TCP (no UDP at this time)
7171

72+
Docker container
73+
----------------
74+
You can run microsocks in a docker container:
75+
76+
docker run --init -d -p 7777:1080 ghcr.io/rofl0r/microsocks
77+
78+
Replace 7777 with the port microsocks will be accessible on.
79+
7280
Troubleshooting
7381
---------------
7482

0 commit comments

Comments
 (0)