Skip to content

Commit

Permalink
Feature docker (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
yas-nyan authored Oct 14, 2023
1 parent aec3ebd commit aa5bd23
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
31 changes: 30 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,33 @@ jobs:
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker_build_and_push:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Get the version
id: get_version
run: echo "::set-output name=VERSION::${GITHUB_REF#refs/tags/v}"

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/sockmon:${{ steps.get_version.outputs.VERSION }}
ghcr.io/${{ github.repository_owner }}/sockmon:latest
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.21.3-bullseye as builder
WORKDIR /usr/src/sockmon

COPY . .
RUN make

FROM debian:bullseye-slim
RUN apt-get update && apt-get install iproute2 -y && apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/src/sockmon/bin/sockmon /bin/sockmon

ENTRYPOINT ["/bin/sockmon"]
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
BIN_DIR=bin
BINARY_NAME=sockmon
DOCKER_IMG_TAG ?= latest

all: test build

Expand All @@ -18,3 +19,11 @@ test:
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)

.PHONY: docker-build
docker-build:
docker build -t ghcr.io/wide-vsix/sockmon:$(DOCKER_IMG_TAG) .

.PHONY: docker-push
docker-push:
docker push ghcr.io/wide-vsix/sockmon:$(DOCKER_IMG_TAG)

0 comments on commit aa5bd23

Please sign in to comment.