diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..624c0cc --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,39 @@ +name: push +on: + push: + tags: + - '*' + +env: + DOCKER_REPO: codex-team/opencollective-webhook + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: docker://golangci/golangci-lint:v1.41.1 + with: + args: golangci-lint run + + build: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - 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 production image + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ endsWith(github.ref, 'refs/tags/v') }} + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..46bd34e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.16-alpine as build + +WORKDIR /app + +COPY go.mod ./ +COPY go.sum ./ + +RUN go mod download + +COPY *.go ./ + +RUN go build -o /opencollective-webhook + +FROM alpine:3.14.1 + +WORKDIR / + +COPY --from=build /opencollective-webhook /opencollective-webhook + +COPY .env ./ + +ENTRYPOINT ["/opencollective-webhook"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f02d2d3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3.8" + +services: + app: + build: + dockerfile: ./Dockerfile + context: . + restart: on-failure \ No newline at end of file