Skip to content

Commit 17ebb08

Browse files
committed
Add Dockerfile and Github Actions workflow
1 parent 96bf8a8 commit 17ebb08

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

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

0 commit comments

Comments
 (0)