From 9f4fc3669ba56140f158f404247ea7e2721b30f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Christian=20Gr=C3=BCnhage?= Date: Tue, 4 Dec 2018 13:00:01 +0100 Subject: [PATCH] Reduce container image size --- contrib/docker/Dockerfile | 28 ++++++++++++++++------------ contrib/docker/entrypoint.sh | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) mode change 100644 => 100755 contrib/docker/entrypoint.sh diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index a5174eb4..6b4bfcb6 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -1,18 +1,22 @@ -FROM golang:stretch -MAINTAINER Christer Waren/CWINFO "christer.waren@cwinfo.org" - -RUN apt-get update \ - && apt-get upgrade -y - -ADD . /src +FROM docker.io/golang:alpine as builder +COPY . /src WORKDIR /src +RUN apk add git && ./build -RUN adduser --system --home /etc/yggdrasil-network --uid 1000 yggdrasil-network \ - && rm -rf build_* && ./build \ - && cp yggdrasil /usr/bin \ - && cp contrib/docker/entrypoint.sh / +FROM docker.io/alpine +LABEL maintainer="Christer Waren/CWINFO " + +COPY --from=builder /src/yggdrasil /usr/bin/yggdrasil +COPY --from=builder /src/yggdrasilctl /usr/bin/yggdrasilctl +COPY contrib/docker/entrypoint.sh /usr/bin/entrypoint.sh + +# RUN addgroup -g 1000 -S yggdrasil-network \ +# && adduser -u 1000 -S -g 1000 --home /etc/yggdrasil-network yggdrasil-network +# +# USER yggdrasil-network +# TODO: Make running unprivileged work VOLUME [ "/etc/yggdrasil-network" ] -ENTRYPOINT [ "/entrypoint.sh" ] +ENTRYPOINT [ "/usr/bin/entrypoint.sh" ] diff --git a/contrib/docker/entrypoint.sh b/contrib/docker/entrypoint.sh old mode 100644 new mode 100755 index f1a9d3e5..26c685a8 --- a/contrib/docker/entrypoint.sh +++ b/contrib/docker/entrypoint.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e