Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Adds GitHub Action build #63

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build registrator and containers
on:
workflow_dispatch:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- master
pull_request:
branches:
- master
jobs:
prep:
outputs:
branch: ${{ steps.extract_branch.outputs.branch }}
runs-on: [self-hosted, linux]
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
build:
needs: prep
runs-on: [self-hosted, linux]
strategy:
matrix:
os: [linux, windows]
steps:
- uses: actions/checkout@v2
- name: create registrator build container
run: |
docker build -t registrator-build:${{ matrix.os }} --build-arg OS=${{ matrix.os }} --build-arg ARCH=amd64 -f Dockerfile.build .
- name: run build container
run: |
mkdir ./output
docker run -v ./output:/out registrator-build:${{ matrix.os }} build -ldflags "-X main.Version=$(cat VERSION)" -o /out/registrator
- name: upload registrator binary
uses: actions/upload-artifact@v2
with:
name: registrator-${{ matrix.os }}
path: output
retention-days: 1
container:
needs:
- build
- prep
runs-on: [self-hosted, "${{ matrix.os }}"]
strategy:
matrix:
os: [linux, windows]
steps:
- name: download registrator binary
uses: actions/download-artifact@v2
with:
name: registrator-${{ matrix.os }}
- name: create registator runtime container
env:
AWS_REGION: us-east-1
run: |
docker build -t registrator:${{ matrix.os }}.${{ github.run_id }} -f Dockerfile.${{ matrix.os }} .
docker tag registrator:${{ matrix.os }}.${{ github.run_id }} ${{ secrets.AWS_WEB_ACCT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/registrator:${{ matrix.os }}.${{ needs.prep.outputs.branch }}.${{ github.run_id }}
docker login --username AWS -p $(aws ecr get-login-password --region ${{ env.AWS_REGION }} ) ${{ secrets.AWS_WEB_ACCT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
docker push ${{ secrets.AWS_WEB_ACCT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/registrator:${{ matrix.os }}.${{ needs.prep.outputs.branch }}.${{ github.run_id }}
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

23 changes: 23 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:3.8

ENV GOPATH /go
WORKDIR /go/src/github.com/gliderlabs/registrator
COPY . .

RUN apk --no-cache add -t build-deps build-base go git \
&& apk --no-cache add ca-certificates bash coreutils \
&& cd /go/src/github.com/gliderlabs/registrator \
&& export GOPATH=/go \
&& git config --global http.https://gopkg.in.followRedirects true

ARG OS="linux"
ARG ARCH="amd64"
ENV GOOS=${OS}
ENV GOARCH=${ARCH}

RUN go get

CMD ["go"]


#&& go build -ldflags "-X main.Version=$(cat VERSION)" -o /bin/registrator \
7 changes: 7 additions & 0 deletions Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.8
ENTRYPOINT ["/bin/run-registrator.sh"]

RUN mkdir /logs
COPY ./run-registrator.sh /bin
RUN chmod 755 /bin/run-registrator.sh
COPY ./output/registrator /bin/registrator
5 changes: 5 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR C:\\app
COPY ./output/registrator registrator.exe
ENTRYPOINT ["C:\\app\\registrator.exe"]