From 0d8cacdb90a8a87fd0a8aeaf79cc7e8577a56c6d Mon Sep 17 00:00:00 2001 From: Lokowitz Date: Sun, 31 Aug 2025 07:22:32 +0000 Subject: [PATCH 1/2] added docker version of olm --- .github/workflows/cicd.yml | 16 ++++++++++++++++ Dockerfile | 4 ++-- Makefile | 11 +++++++++++ docker-compose.yml | 15 +++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 5dee76a..a11b02d 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -14,6 +14,18 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Extract tag name id: get-tag run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV @@ -32,6 +44,10 @@ jobs: else echo "main.go not found" fi + - name: Build and push Docker images + run: | + TAG=${{ env.TAG }} + make docker-build-release tag=$TAG - name: Build binaries run: | diff --git a/Dockerfile b/Dockerfile index 8be25da..8dd78c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,9 @@ COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -o /olm # Start a new stage from scratch -FROM ubuntu:24.04 AS runner +FROM alpine:3.22 AS runner -RUN apt-get update && apt-get install ca-certificates -y && rm -rf /var/lib/apt/lists/* +RUN apk --no-cache add ca-certificates # Copy the pre-built binary file from the previous stage and the entrypoint script COPY --from=builder /olm /usr/local/bin/ diff --git a/Makefile b/Makefile index 2a09ad9..433e275 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,20 @@ all: go-build-release +docker-build-release: + @if [ -z "$(tag)" ]; then \ + echo "Error: tag is required. Usage: make docker-build-release tag="; \ + exit 1; \ + fi + docker buildx build --platform linux/arm/v7,linux/arm64,linux/amd64 -t fosrl/olm:latest -f Dockerfile --push . + docker buildx build --platform linux/arm/v7,linux/arm64,linux/amd64 -t fosrl/olm:$(tag) -f Dockerfile --push . + local: CGO_ENABLED=0 go build -o olm +build: + docker build -t fosrl/olm:latest . + go-build-release: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/olm_linux_arm64 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/olm_linux_amd64 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8598c84 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +services: + olm: + image: fosrl/olm:latest + container_name: olm + restart: unless-stopped + environment: + - PANGOLIN_ENDPOINT=https://example.com + - OLM_ID=vdqnz8rwgb95cnp + - OLM_SECRET=1sw05qv1tkfdb1k81zpw05nahnnjvmhxjvf746umwagddmdg + cap_add: + - NET_ADMIN + - SYS_MODULE + devices: + - /dev/net/tun:/dev/net/tun + network_mode: host \ No newline at end of file From 82555f409b2e6066081e6c720dbb24d3b82bebad Mon Sep 17 00:00:00 2001 From: Lokowitz Date: Sun, 31 Aug 2025 07:33:41 +0000 Subject: [PATCH 2/2] added build of docker image to test --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52fc2a4..13dd489 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,5 +21,8 @@ jobs: - name: Build go run: go build + - name: Build Docker image + run: make build + - name: Build binaries run: make go-build-release