Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify how the docker image is built #124

Merged
merged 1 commit into from
Dec 4, 2018
Merged
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
21 changes: 20 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# build stage
FROM golang:1.11.1-alpine AS build-env

ENV GOPATH /go
ENV GOOS linux

RUN apk add --update git bash

ADD packaging/install-vips.sh install-vips.sh
RUN ./install-vips.sh

ADD . /go/src/github.com/zalando-stups/skrop
WORKDIR /go/src/github.com/zalando-stups/skrop

RUN go get github.com/Masterminds/glide

RUN go build ./cmd/skrop

# final stage
FROM danpersa/alpine-mozjpeg-vips:3.3.1-8.7.0

ARG ROUTES_FILE

ADD skrop /usr/local/bin/
COPY --from=0 /go/src/github.com/zalando-stups/skrop/skrop /usr/local/bin/
ADD $ROUTES_FILE skrop.eskip

ENTRYPOINT skrop -routes-file skrop.eskip ${SKROP_ARGS}
8 changes: 0 additions & 8 deletions packaging/Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions packaging/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,13 @@ readonly DOCKER_IMAGE_NAME=${3-"zalando-stups/skrop"}

readonly GO_PROJECT_NAME="github.com/zalando-stups/skrop"

function make_build_image() {
docker build -t "$DOCKER_IMAGE_NAME-build" packaging/ \
&& return 0
}

function make_binary() {
docker run --rm \
-v ${PWD}:/go/src/${GO_PROJECT_NAME} \
-e "GOPATH=/go" \
-e "GOOS=linux" \
-w /go/src/${GO_PROJECT_NAME} \
"$DOCKER_IMAGE_NAME-build" sh \
-c 'go build ./cmd/skrop' \
&& return 0
}

function make_production_image() {
docker build \
--build-arg ROUTES_FILE=${ROUTES_FILE} \
-t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} . \
&& return 0
}

echo >&2 "Building build Docker image…"

make_build_image
if [ "$?" -ne 0 ]; then
echo >&2 "Aborting!"
exit 1
fi

echo >&2 "Building binary…"

make_binary
if [ "$?" -ne 0 ]; then
echo >&2 "Aborting!"
exit 1
fi

echo >&2 "Building Docker image…"

make_production_image
Expand Down