Skip to content

Commit

Permalink
Split Dockerfile for better build speed, added fixed image tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Gallucci committed Mar 3, 2021
1 parent 7583b68 commit 4e4788f
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine as curl
FROM alpine:3.12.4 as curl

WORKDIR /

Expand All @@ -13,23 +13,40 @@ ARG YQ_BINARY="yq_${OS}_$ARCH"
RUN wget "https://github.com/mikefarah/yq/releases/download/$YQ_VERSION/$YQ_BINARY" -O /usr/local/bin/yq && \
chmod +x /usr/local/bin/yq

FROM ubuntu:groovy as fuse-builder
WORKDIR /build
FROM curl as img-downloader

ARG IMG_SHA256="cc9bf08794353ef57b400d32cd1065765253166b0a09fba360d927cfbd158088"
RUN curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/docker" \
&& ( echo "${IMG_SHA256} /usr/bin/docker" | sha256sum -c - ) \
&& chmod a+x "/usr/bin/docker"


FROM ubuntu:groovy-20210115 as fuse-downloader

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
libc6-dev gcc g++ make automake autoconf clang pkgconf libfuse3-dev git \
ca-certificates \
git ca-certificates \
&& update-ca-certificates && \
rm -rf /var/lib/apt/lists/*

WORKDIR /build
RUN git clone https://github.com/containers/fuse-overlayfs.git -b v1.4.0

FROM ubuntu:groovy-20210115 as fuse-builder
WORKDIR /build
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
libc6-dev gcc g++ make automake autoconf clang pkgconf libfuse3-dev \
&& rm -rf /var/lib/apt/lists/*

COPY --from=fuse-downloader /build /build
RUN cd fuse-overlayfs && \
sh autogen.sh && \
LIBS="-ldl" LDFLAGS="-static" ./configure --prefix /usr && \
make


FROM ubuntu:groovy
FROM ubuntu:groovy-20210115

RUN apt-get update && \
apt-get install -y software-properties-common && \
Expand All @@ -49,8 +66,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-instal

WORKDIR /app

RUN mknod /dev/fuse -m 0666 c 10 229

COPY dep-bootstrap.sh .
RUN chmod +x ./dep-bootstrap.sh

Expand All @@ -59,11 +74,7 @@ USER root
RUN useradd -u 1000 -s /bin/bash jenkins
RUN mkdir -p /home/jenkins
RUN chown 1000:1000 /home/jenkins
RUN export IMG_SHA256="cc9bf08794353ef57b400d32cd1065765253166b0a09fba360d927cfbd158088" \
&& curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/docker" \
&& echo "${IMG_SHA256} /usr/bin/docker" | sha256sum -c - \
&& chmod a+x "/usr/bin/docker" \
&& export IMG_DISABLE_EMBEDDED_RUNC=1 \
RUN export IMG_DISABLE_EMBEDDED_RUNC=1 \
&& chmod u-s /usr/bin/newuidmap /usr/bin/newgidmap \
&& echo "jenkins:100000:65536" > /etc/subgid \
&& echo "jenkins:100000:65536" > /etc/subuid \
Expand All @@ -73,6 +84,7 @@ RUN export IMG_SHA256="cc9bf08794353ef57b400d32cd1065765253166b0a09fba360d927cfb

ENV JENKINS_USER=jenkins

COPY --from=img-downloader --chown=1000:1000 /usr/bin/docker /usr/bin/docker
COPY --from=yq-downloader --chown=1000:1000 /usr/local/bin/yq /usr/local/bin/yq
COPY --from=fuse-builder --chown=1000:1000 /build/fuse-overlayfs/fuse-overlayfs /usr/bin/fuse-overlayfs

Expand Down

0 comments on commit 4e4788f

Please sign in to comment.