Add basic tools to Dockerfile (#255)

* Update Dockerfile

Add bind-tools and ca-certificates to Docker Image

* Support for non-root container

Added glider user and group to final image. Support for running Glider container as non-root user. Build image is now pinned to Golang 1.16 to avoid future issues when 1.17 is released.
This commit is contained in:
Juan Calderon-Perez 2021-04-21 21:53:47 -04:00 committed by GitHub
parent dbd2e04521
commit bcf17ade29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,25 @@
# build stage
FROM golang:alpine AS build-env
RUN apk --no-cache add build-base git gcc
ADD . /src
RUN cd /src && go build -v -ldflags "-s -w"
# Build Stage
FROM golang:1.16-alpine AS build-env
# final stage
ADD . /src
RUN apk --no-cache add build-base git gcc \
&& cd /src && go build -v -ldflags "-s -w"
# Final Stage
FROM alpine
WORKDIR /app
COPY --from=build-env /src/glider /app/
RUN apk -U upgrade \
&& apk add bind-tools ca-certificates shadow \
&& groupadd -g 1000 glider \
&& useradd -r -u 1000 -g glider glider \
&& apk del shadow \
&& chown -R glider:glider /app
&& apk -v cache clean
WORKDIR /app
USER glider
ENTRYPOINT ["./glider"]