Skip to content

Commit

Permalink
Build binaries as part of Docker
Browse files Browse the repository at this point in the history
Moving the binary compilation as part of Docker we will be able to
leverage the multi architecture support Docker has to provide images
that can run on different architecture such as x64_86, ARM.

Signed-off-by: Gianluca Arbezzano <[email protected]>
  • Loading branch information
Gianluca Arbezzano committed Oct 27, 2020
1 parent 9e7d539 commit f959df8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 62 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deploy
47 changes: 0 additions & 47 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,6 @@ jobs:
run: go test -coverprofile=coverage.txt ./...
- name: upload codecov
run: bash <(curl -s https://codecov.io/bash)
- name: Build binaries
run: make
- name: Upload tink-server binary
uses: actions/upload-artifact@v2
with:
name: tink-server
path: ./cmd/tink-server/tink-server
- name: Upload tink-cli binary
uses: actions/upload-artifact@v2
with:
name: tink-cli
path: ./cmd/tink-cli/tink-cli
- name: Upload tink-worker binary
uses: actions/upload-artifact@v2
with:
name: tink-worker
path: ./cmd/tink-worker/tink-worker
- uses: cachix/install-nix-action@v10
with:
nix_path: nixpkgs=channel:nixos-unstable
Expand All @@ -60,36 +43,6 @@ jobs:
echo ::set-output name=tink-worker-tags::quay.io/tinkerbell/tink-worker:latest,quay.io/tinkerbell/tink-worker:sha-${GITHUB_SHA::8}
- name: Checkout code
uses: actions/checkout@v2
- name: Download tink-cli binary
uses: actions/download-artifact@v2
with:
name: tink-cli
path: ./cmd/tink-cli
- name: Download tink-server binary
uses: actions/download-artifact@v2
with:
name: tink-server
path: ./cmd/tink-server
- name: Download tink-worker binary
uses: actions/download-artifact@v2
with:
name: tink-worker
path: ./cmd/tink-worker
- name: set tink-worker permission
run: chmod +x ./cmd/tink-worker/tink-worker
- name: set tink-cli permission
run: chmod +x ./cmd/tink-cli/tink-cli
- name: set tink-server permission
run: chmod +x ./cmd/tink-server/tink-server
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to quay.io
uses: docker/login-action@v1
if: ${{ startsWith(github.ref, 'refs/heads/master') }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: quay.io/tinkerbell/tink
uses: docker/build-push-action@v2
with:
Expand Down
14 changes: 8 additions & 6 deletions cmd/tink-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM alpine:3.11

CMD sleep infinity
FROM golang:1.15-alpine
RUN apk add --no-cache --update --upgrade ca-certificates make git
COPY . /usr/myapp
WORKDIR /usr/myapp
RUN make cli

FROM alpine:3.11
ENTRYPOINT ["/usr/bin/tink-cli"]
RUN apk add --no-cache --update --upgrade ca-certificates

COPY tink-cli /bin/tink
COPY sample.tmpl /tmp
COPY --from=0 /usr/myapp/cmd/tink-cli/tink-cli /usr/bin/tink-cli
12 changes: 8 additions & 4 deletions cmd/tink-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
FROM alpine:3.11
FROM golang:1.15-alpine
RUN apk add --no-cache --update --upgrade ca-certificates make git
COPY . /usr/myapp
WORKDIR /usr/myapp
RUN make server

ENTRYPOINT ["tink-server"]
FROM alpine:3.11
ENTRYPOINT ["/usr/bin/tink-server"]
EXPOSE 42113
EXPOSE 42114

RUN apk add --update ca-certificates && \
apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing cfssl

COPY tink-server /bin/
COPY --from=0 /usr/myapp/cmd/tink-server/tink-server /usr/bin/tink-server
13 changes: 8 additions & 5 deletions cmd/tink-worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM alpine:3.11

ENTRYPOINT [ "/tink-worker" ]
FROM golang:1.15-alpine
RUN apk add --no-cache --update --upgrade ca-certificates make git
COPY . /usr/myapp
WORKDIR /usr/myapp
RUN make worker

FROM alpine:3.11
ENTRYPOINT [ "/usr/bin/tink-worker" ]
RUN apk add --no-cache --update --upgrade ca-certificates

COPY tink-worker /tink-worker
COPY --from=0 /usr/myapp/cmd/tink-worker/tink-worker /usr/bin/tink-worker

0 comments on commit f959df8

Please sign in to comment.