Skip to content

Commit

Permalink
Merge pull request #217 from mdawar/alpine
Browse files Browse the repository at this point in the history
Add Alpine Docker image
  • Loading branch information
oliver006 committed Jan 9, 2019
2 parents 1b148d9 + 15aadb1 commit bdb3216
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# build container
#
FROM golang:1-alpine
FROM golang:1-alpine as builder
WORKDIR /go/src/github.com/oliver006/redis_exporter/

ADD main.go /go/src/github.com/oliver006/redis_exporter/
Expand All @@ -20,15 +20,25 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /redis_exporter \
-ldflags "-s -w -extldflags \"-static\" -X main.VERSION=$TAG -X main.COMMIT_SHA1=$SHA1 -X main.BUILD_DATE=$DATE" .


#
# Alpine release container
#
FROM alpine as alpine

COPY --from=builder /redis_exporter /redis_exporter
COPY --from=builder /etc/ssl/certs /etc/ssl/certs

EXPOSE 9121
ENTRYPOINT [ "/redis_exporter" ]


#
# release container
#
FROM scratch
FROM scratch as scratch

COPY --from=0 /redis_exporter /redis_exporter
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /redis_exporter /redis_exporter
COPY --from=builder /etc/ssl/certs /etc/ssl/certs

EXPOSE 9121
ENTRYPOINT [ "/redis_exporter" ]
37 changes: 25 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,31 @@ echo "docker login done"
export BUILD_ARGS="--rm=false --build-arg TAG=${CIRCLE_TAG} --build-arg SHA1=${CIRCLE_SHA1} --build-arg DATE=$(date +%F-%T)"
echo "BUILD_ARGS: $BUILD_ARGS"

docker build -t "21zoo/redis_exporter:$CIRCLE_TAG" $BUILD_ARGS .
docker push "21zoo/redis_exporter:$CIRCLE_TAG"

docker build -t "21zoo/redis_exporter:latest" $BUILD_ARGS .
docker push "21zoo/redis_exporter:latest"

docker build -t "oliver006/redis_exporter:$CIRCLE_TAG" $BUILD_ARGS .
docker push "oliver006/redis_exporter:$CIRCLE_TAG"

docker build -t "oliver006/redis_exporter:latest" $BUILD_ARGS .
docker push "oliver006/redis_exporter:latest"

# Scratch image
docker build --target scratch \
-t "21zoo/redis_exporter:$CIRCLE_TAG" \
-t "21zoo/redis_exporter:latest" \
-t "oliver006/redis_exporter:$CIRCLE_TAG" \
-t "oliver006/redis_exporter:latest" \
$BUILD_ARGS .

docker push "21zoo/redis_exporter:$CIRCLE_TAG"
docker push "21zoo/redis_exporter:latest"
docker push "oliver006/redis_exporter:$CIRCLE_TAG"
docker push "oliver006/redis_exporter:latest"

# Alpine image
docker build --target alpine \
-t "21zoo/redis_exporter:$CIRCLE_TAG-alpine" \
-t "21zoo/redis_exporter:alpine" \
-t "oliver006/redis_exporter:$CIRCLE_TAG-alpine" \
-t "oliver006/redis_exporter:alpine" \
$BUILD_ARGS .

docker push "21zoo/redis_exporter:$CIRCLE_TAG-alpine"
docker push "21zoo/redis_exporter:alpine"
docker push "oliver006/redis_exporter:$CIRCLE_TAG-alpine"
docker push "oliver006/redis_exporter:alpine"


echo "Building binaries for Github"
Expand Down

0 comments on commit bdb3216

Please sign in to comment.