Skip to content

Commit

Permalink
Add Dockerfile (#80)
Browse files Browse the repository at this point in the history
* add dockerfile

* add docker build to circleci

* fix messages

* add build config

* fix circle config

* use orb

* fix go version

* build from scratch

* remove extra refs

* fix config location

* fix rok8s

* remove old job

* add ARG directives

* change CMD to ENTRYPOINT
  • Loading branch information
rbren authored Jun 5, 2020
1 parent 81c8d32 commit 520efde
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .circleci/build.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DOCKERFILE='Dockerfile'

EXTERNAL_REGISTRY_BASE_DOMAIN=quay.io
REPOSITORY_NAME=fairwinds/pluto
DOCKERTAG=${EXTERNAL_REGISTRY_BASE_DOMAIN}/${REPOSITORY_NAME}
if [[ -n $CI_TAG ]]; then
ADDITIONAL_DOCKER_TAG_VERSIONS=()
ADDITIONAL_DOCKER_TAG_VERSIONS+=(`echo $CI_TAG | sed -e 's/\(\w\+\)\..*$/\1/'`)
ADDITIONAL_DOCKER_TAG_VERSIONS+=(`echo $CI_TAG | sed -e 's/\(\w\+\.\w\+\)\..*$/\1/'`)
fi
39 changes: 35 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
- run: go test -v ./... -coverprofile=coverage.txt -covermode=atomic
- run: bash <(curl -s https://codecov.io/bash)

release:
release_binary:
working_directory: /go/src/github.com/fairwindsops/pluto
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.14
environment:
GO111MODULE: "on"
steps:
Expand All @@ -60,7 +60,38 @@ jobs:

workflows:
version: 2
test-and-release:

test:
jobs:
- test
- rok8s-scripts/docker_build_and_push:
name: build-container
docker-push: false
enable_docker_layer_caching: true
config_file: .circleci/build.config
password-variable: "fairwinds_quay_token"
requires:
- test
filters:
branches:
only: /pull\/[0-9]+/
- rok8s-scripts/docker_build_and_push:
name: build-and-push-container
docker-push: true
enable_docker_layer_caching: true
config_file: .circleci/build.config
context: org-global
docker-login: true
password-variable: "fairwinds_quay_token"
registry: quay.io
username: fairwinds+circleci
requires:
- test
filters:
branches:
ignore: /pull\/[0-9]+/

release:
jobs:
- test:
filters:
Expand All @@ -69,7 +100,7 @@ workflows:
- rok8s-scripts/kubernetes_e2e_tests:
name: run functional tests
<<: *e2e_config
- release:
- release_binary:
filters:
branches:
ignore: /.*/
Expand Down
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM golang:1.14.3 AS build-env
WORKDIR /go/src/github.com/fairwindsops/pluto/

ARG version=dev
ARG commit=none

COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN VERSION=$version COMMIT=$commit make build-linux


FROM alpine:3.12.0 as alpine
RUN apk --no-cache --update add ca-certificates tzdata && update-ca-certificates


FROM scratch
COPY --from=alpine /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=alpine /etc/passwd /etc/passwd

USER nobody
COPY --from=build-env /go/src/github.com/fairwindsops/pluto /

WORKDIR /opt/app

ENTRYPOINT ["/pluto"]

0 comments on commit 520efde

Please sign in to comment.