Skip to content

Commit

Permalink
Merge pull request #463 from pseudomuto/push_to_docker_on_tag
Browse files Browse the repository at this point in the history
Publish to DockerHub when a new tag is created
  • Loading branch information
pseudomuto committed Oct 17, 2021
2 parents 4361808 + 16c28d2 commit c3f4578
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 47 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/dockerhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy Docker Image

on:
create: ~

jobs:
deploy:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: pseudomuto/protoc-gen-doc:${{ github.sha }}, pseudomuto/protoc-gen-doc:latest
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM debian:jessie-slim
FROM golang:1.17-alpine AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o protoc-gen-doc ./cmd/protoc-gen-doc

FROM debian:jessie-slim AS final
LABEL maintainer="pseudomuto <david.muto@gmail.com>" protoc_version="3.6.1"

WORKDIR /
Expand All @@ -12,8 +19,8 @@ RUN apt-get -q -y update && \
apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

ADD dist/protoc-gen-doc /usr/local/bin/
ADD script/entrypoint.sh ./
COPY --from=builder /build/protoc-gen-doc /usr/local/bin
COPY script/entrypoint.sh ./

VOLUME ["/out", "/protos"]

Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DOCKER_CMD=docker run --rm \
-v $(PWD)/thirdparty/github.com/mwitkow:/usr/local/include/github.com/mwitkow:ro \
-v $(PWD)/thirdparty/github.com/envoyproxy:/usr/local/include/github.com/envoyproxy:ro \
-v $(PWD)/tmp/googleapis/google/api:/usr/local/include/google/api:ro \
pseudomuto/protoc-gen-doc
pseudomuto/protoc-gen-doc:local

VERSION = $(shell cat version.go | sed -n 's/.*const VERSION = "\(.*\)"/\1/p')

Expand Down Expand Up @@ -49,11 +49,9 @@ build: resources.go
dist:
@script/dist.sh

docker:
@script/push_to_docker.sh

docker_test: build tmp/googleapis docker
docker_test: tmp/googleapis
@rm -f examples/doc/*
@docker build -t pseudomuto/protoc-gen-doc:local .
@$(DOCKER_CMD) --doc_opt=docbook,example.docbook:Ignore*
@$(DOCKER_CMD) --doc_opt=html,example.html:Ignore*
@$(DOCKER_CMD) --doc_opt=json,example.json:Ignore*
Expand Down
39 changes: 0 additions & 39 deletions script/push_to_docker.sh

This file was deleted.

0 comments on commit c3f4578

Please sign in to comment.