ae7a13db21
* Add multistaged build effectively reducing image size * Change deprecated MAINTAINER to LABEL * Change ADD to COPY * Start container as a non-root user
28 lines
747 B
Docker
28 lines
747 B
Docker
FROM golang:alpine AS build-env
|
|
LABEL maintainer "Jimmy Zelinskie <jimmyzelinskie@gmail.com>"
|
|
|
|
# Install OS-level dependencies.
|
|
RUN apk update && \
|
|
apk add curl git && \
|
|
curl https://glide.sh/get | sh
|
|
|
|
# Copy our source code into the container.
|
|
WORKDIR /go/src/github.com/chihaya/chihaya
|
|
COPY . /go/src/github.com/chihaya/chihaya
|
|
|
|
# Install our golang dependencies and compile our binary.
|
|
RUN glide install
|
|
RUN CGO_ENABLED=0 GOOS=linux go install github.com/chihaya/chihaya/cmd/chihaya
|
|
RUN adduser -D chihaya
|
|
|
|
FROM scratch
|
|
COPY --from=build-env /go/bin/chihaya /chihaya
|
|
COPY --from=build-env /etc/passwd /etc/passwd
|
|
|
|
# Expose a docker interface to our binary.
|
|
EXPOSE 6880 6881
|
|
|
|
# Drop root privileges
|
|
USER chihaya
|
|
|
|
ENTRYPOINT ["/chihaya"]
|