-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (36 loc) · 1.15 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
38
39
40
41
42
43
44
45
46
47
48
# Build stage
FROM golang:alpine3.8 AS build-env
# Install git
RUN apk add --no-cache git
# Install golang depencencies
RUN go get github.com/docker/docker/client && \
go get github.com/lobre/goodhosts && \
go get github.com/iancoleman/strcase && \
go get -u github.com/prometheus/client_golang/prometheus/promhttp
# Add sources
ADD . /src
# Build app
RUN cd /src && go build -o ghosts
# --------
# Final stage
FROM alpine:3.8
# Install docker client
ARG DOCKER_CLI_VERSION="18.06.1-ce"
ENV DOWNLOAD_URL="https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLI_VERSION.tgz"
RUN apk --update add curl \
&& mkdir -p /tmp/download \
&& curl -L $DOWNLOAD_URL | tar -xz -C /tmp/download \
&& mv /tmp/download/docker/docker /usr/local/bin/ \
&& rm -rf /tmp/download \
&& apk del curl \
&& rm -rf /var/cache/apk/*
# Copy go binary, static and html template
COPY --from=build-env /src/ghosts /app/
COPY --from=build-env /src/index.html /app/
COPY --from=build-env /src/static/ /app/static/
# Define workdir
WORKDIR /app
EXPOSE 8080
# Create fake hosts file
RUN touch /app/hosts
ENTRYPOINT ["./ghosts", "-hosts=/app/hosts"]