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"]