diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..0fe40ff1 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,43 @@ +name: Create and publish a Docker image +on: + push: + branches: + - 'master' + tags: + - ".*" + pull_request: + paths: + - Dockerfile + - .github/workflows/docker.yml +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Log in to the Container registry + uses: docker/login-action@master + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta-drafter + uses: docker/metadata-action@master + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/drafter + + - name: Build and push drafter Docker image + uses: docker/build-push-action@master + with: + push: true + tags: ${{ steps.meta-drafter.outputs.tags }} + labels: ${{ steps.meta-drafter.outputs.labels }} + target: drafter + no-cache-filters: drafter-build,drafter + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 967dc6d9..28e7d833 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,18 @@ -FROM alpine:3.10 as build +FROM debian:bullseye-slim AS drafter-build MAINTAINER Apiary "sre@apiary.io" -WORKDIR /usr/src/drafter - -ADD CMakeLists.txt DefaultBuildType.cmake ./ -ADD packages packages +COPY . /usr/src/drafter -WORKDIR /tmp/drafter - -RUN apk add --no-cache cmake make g++ -RUN cmake /usr/src/drafter +WORKDIR /usr/src/drafter -RUN make drafter -RUN make install +RUN apt-get install --yes cmake g++ -FROM alpine:3.10 +RUN cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build +RUN cmake --install build -RUN apk add --no-cache gcc -COPY --from=build /usr/local/bin/drafter /usr/local/bin/drafter +FROM debian:bullseye-slim AS drafter +COPY --from=drafter-build /usr/local/bin/drafter /usr/local/bin/drafter ADD LICENSE /usr/local/share/licenses/drafter/LICENSE CMD drafter