-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile
42 lines (30 loc) · 846 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
FROM golang:alpine AS build-env
# Injest build args from Makefile
ARG BINARY=go-boilerplate
ARG GITHUB_USERNAME=myusername
ARG GOARCH=amd64
# Set up dependencies
ENV PACKAGES make git curl
# Set working directory for the build
WORKDIR /go/src/github.com/${GITHUB_USERNAME}/${BINARY}
# Install dependencies
RUN apk add --update $PACKAGES
# Install dep
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# Add source files
COPY . .
# Make the binary
RUN make install
# Final image
FROM alpine:edge
ARG BINARY=go-boilerplate
ARG GITHUB_USERNAME=myusername
ARG GOARCH=amd64
ENV BINARY=${BINARY}
# Install ca-certificates
RUN apk add --update ca-certificates
WORKDIR /root
# Copy over binaries from the build-env
COPY --from=build-env /go/bin/${BINARY} /usr/bin/${BINARY}
# Run ${BINARY} by default
CMD ${BINARY}