From e5a56ec5c8c6d1e26c9fdb0870f2de9bf7256ed9 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sun, 25 Jun 2023 12:43:18 -0400 Subject: [PATCH] Docker deployment --- .github/workflows/docker.yml | 30 ++++++++++++++++++++++++++++++ Dockerfile | 15 +++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..20ccd3f --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,30 @@ +name: Docker + +on: + push: + branches: [ master ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Docker Login + uses: azure/docker-login@v1 + with: + login-server: docker.pkg.github.com + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + run: docker build -t image . + + - name: Publish + run: | + docker tag image docker.pkg.github.com/pangbox/server/minibox:${GITHUB_SHA} + docker push docker.pkg.github.com/pangbox/server/minibox:${GITHUB_SHA} + docker tag image docker.pkg.github.com/pangbox/server/minibox:latest + docker push docker.pkg.github.com/pangbox/server/minibox:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..71cf8ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM docker.io/golang:1.20.5-alpine AS builder +WORKDIR /src +COPY go.mod . +COPY go.sum . +RUN go mod download +COPY . . +RUN go build -o /server ./cmd/minibox + +FROM docker.io/alpine:latest +EXPOSE 8080/tcp 10101/tcp 20202/tcp 30303/tcp +USER 1000:1000 +COPY --from=builder /server /server +WORKDIR /minibox +VOLUME /minibox +ENTRYPOINT ["/server", "-pangya_dir", "/pangya"]