From 5c0f5754ed6e00b9aab504dfda6d7beb27fc83a9 Mon Sep 17 00:00:00 2001 From: meanwhile131 <51206659+meanwhile131@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:56:27 +0400 Subject: [PATCH] Add Dockerfile and Github Actions workflow --- .dockerignore | 3 ++ .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 11 +++++++ README.md | 8 +++++ 5 files changed, 85 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ab5ab3a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +*.o +*.out +out diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..20844d4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: Docker Image CI + +on: + push: + branches: [ master ] + tags: [ v* ] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: docker-meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=sha,prefix= + type=ref,event=tag + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x + tags: ${{ steps.docker-meta.outputs.tags }} + labels: ${{ steps.docker-meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: type=local,dest=${{ github.workspace }}/out + + - name: Get metadata for artifact naming + id: meta + run: | + echo "commit-hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "repo-name=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT + + - name: Upload built binaries + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.meta.outputs.repo-name }}-${{ steps.meta.outputs.commit-hash }} + path: ${{ github.workspace }}/out diff --git a/.gitignore b/.gitignore index c9c6b85..b24f564 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o *.out +out diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4379cad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine AS builder +RUN apk add --no-cache make gcc libc-dev +WORKDIR /app +ENV LDFLAGS=-static +COPY . . +RUN make + +FROM scratch +LABEL org.opencontainers.image.licenses=MIT +COPY --from=builder /app/microsocks / +ENTRYPOINT ["/microsocks"] \ No newline at end of file diff --git a/README.md b/README.md index 2b7a04a..c8d5388 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,14 @@ Supported SOCKS5 Features - IPv4, IPv6, DNS - TCP (no UDP at this time) +Docker container +---------------- +You can run microsocks in a docker container: + + docker run --init -d -p 7777:1080 ghcr.io/rofl0r/microsocks + +Replace 7777 with the port microsocks will be accessible on. + Troubleshooting ---------------