-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (26 loc) · 1.09 KB
/
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
# Use Go image for building of binary executable.
FROM golang:1.10 AS builder
# Install dep so that dependencies can be installed.
RUN apt-get update && apt-get install -y unzip --no-install-recommends && \
apt-get autoremove -y && apt-get clean -y && \
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# Create classic GOPATH structure.
RUN mkdir -p /go/src/github.com/sweettea-io/build-server
# Switch to project dir as new working dir.
WORKDIR /go/src/github.com/sweettea-io/build-server
# Copy files needed by dep in order to install dependencies.
COPY Gopkg.toml Gopkg.lock ./
# Install dependencies.
RUN dep ensure -vendor-only
# Copy this project into working dir.
COPY . .
# Build Go binary.
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -o main .
# Switch over to Docker-in-Docker image.
FROM docker:dind
# Set working dir to /root inside Docker-in-Docker image.
WORKDIR /root
# Copy Go binary built in first image over to this image.
COPY --from=builder /go/src/github.com/sweettea-io/build-server/main ./main
# Execute Go binary.
ENTRYPOINT ["./main"]