Skip to content

Commit

Permalink
Reduce image size, copy with chown flag
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Jul 24, 2020
1 parent 8c753b6 commit e777dfd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.
17 changes: 6 additions & 11 deletions kotsadm/api/deploy/Dockerfile
Expand Up @@ -35,25 +35,20 @@ RUN curl -L "https://github.com/replicatedhq/troubleshoot/releases/download/v0.9
mv /tmp/troubleshoot.so /lib/troubleshoot.so && \
rm -rf /tmp/*

RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*

ADD ./deploy/policy.json /etc/containers/policy.json
RUN apt-get -y update && apt-get install -y --no-install-recommends \
libgpgme-dev libdevmapper-dev \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /src/build /src/build
COPY --from=build /src/node_modules /src/node_modules
RUN useradd -c 'kotsadm-api user' -m -d /home/kotsadm-api -s /bin/bash -u 1001 kotsadm-api
USER kotsadm-api
ENV HOME /home/kotsadm-api

COPY --from=build --chown=kotsadm-api:kotsadm-api /src/build /src/build
COPY --from=build --chown=kotsadm-api:kotsadm-api /src/node_modules /src/node_modules

EXPOSE 3000
ARG commit=unknown
ENV COMMIT=${commit}

RUN useradd -c 'kotsadm-api user' -m -d /home/kotsadm-api -s /bin/bash -u 1001 kotsadm-api
RUN chown -R kotsadm-api.kotsadm-api /src
USER kotsadm-api
ENV HOME /home/kotsadm-api

CMD ["node", "/src/build/server/index.js"]
15 changes: 6 additions & 9 deletions kotsadm/deploy/Dockerfile
Expand Up @@ -25,15 +25,12 @@ RUN useradd -c 'kotsadm user' -m -d /home/kotsadm -s /bin/bash -u 1001 kotsadm
USER kotsadm
ENV HOME /home/kotsadm

COPY ./deploy/backup.sh /backup.sh
COPY ./deploy/restore-db.sh /restore-db.sh
COPY ./deploy/restore-s3.sh /restore-s3.sh
COPY ./bin/kotsadm /kotsadm
COPY ./web/dist /web/dist
USER root
RUN chmod a+x /kotsadm
RUN chmod a+w /web/dist/*
USER kotsadm
COPY --chown=kotsadm:kotsadm ./deploy/backup.sh /backup.sh
COPY --chown=kotsadm:kotsadm ./deploy/restore-db.sh /restore-db.sh
COPY --chown=kotsadm:kotsadm ./deploy/restore-s3.sh /restore-s3.sh
COPY --chown=kotsadm:kotsadm ./bin/kotsadm /kotsadm
COPY --chown=kotsadm:kotsadm ./web/dist /web/dist

WORKDIR /

EXPOSE 3000
Expand Down
9 changes: 3 additions & 6 deletions kotsadm/kurl_proxy/deploy/Dockerfile
Expand Up @@ -9,12 +9,9 @@ RUN useradd -c 'kotsadm user' -m -d /home/kotsadm -s /bin/bash -u 1001 kotsadm
USER kotsadm
ENV HOME /home/kotsadm

COPY ./bin/kurl_proxy /kurl_proxy
COPY ./assets /assets
USER root
RUN chmod a+x /kurl_proxy
RUN chmod a+w /assets/*
USER kotsadm
COPY --chown=kotsadm:kotsadm ./bin/kurl_proxy /kurl_proxy
COPY --chown=kotsadm:kotsadm ./assets /assets

WORKDIR /

EXPOSE 8800
Expand Down
7 changes: 2 additions & 5 deletions kotsadm/operator/deploy/Dockerfile
Expand Up @@ -29,14 +29,11 @@ USER kotsadm-operator
ENV HOME /home/kotsadm-operator

# Install krew
ADD ./deploy/install-krew.sh /install-krew.sh
COPY --chown=kotsadm-operator:kotsadm-operator ./deploy/install-krew.sh /install-krew.sh
RUN /install-krew.sh
ENV PATH="$HOME/.krew/bin:$PATH"

COPY ./bin/kotsadm-operator /kotsadm-operator
USER root
RUN chmod a+x /kotsadm-operator
USER kotsadm-operator
COPY --chown=kotsadm-operator:kotsadm-operator ./bin/kotsadm-operator /kotsadm-operator

# Install our plugins
USER root
Expand Down

0 comments on commit e777dfd

Please sign in to comment.