Skip to content

Commit

Permalink
Create a more compact docker image (remove dev packages from image) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lavirott authored Mar 25, 2023
1 parent 5ecb0ee commit 67f6294
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@ FROM alpine:latest

LABEL maintainer="[email protected]"

ARG UID=1337
ARG GID=1337
ENV RESTORE false
ENV ARCHIVE_FILE ""

RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk --no-cache add python3-dev libffi-dev gcc libc-dev py3-pip py3-cffi py3-cryptography ca-certificates bash
ENV DEV_PACKAGES="\
gcc \
libc-dev \
libffi-dev \
py3-pip \
python3-dev \
"

ENV PACKAGES="\
bash \
ca-certificates \
py3-cffi \
py3-cryptography \
py3-six \
"
WORKDIR /opt/grafana-backup-tool
ADD . /opt/grafana-backup-tool

RUN chmod -R a+r /opt/grafana-backup-tool \
&& find /opt/grafana-backup-tool -type d -print0 | xargs -0 chmod a+rx

RUN pip3 --no-cache-dir install .
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk add --no-cache --virtual build-deps ${DEV_PACKAGES} \
&& apk add --no-cache ${PACKAGES} \
&& pip3 --no-cache-dir install . \
&& chown -R ${UID}:${GID} /opt/grafana-backup-tool \
&& apk del build-deps

RUN chown -R 1337:1337 /opt/grafana-backup-tool
USER 1337
USER ${UID}
CMD sh -c 'if [ "$RESTORE" = true ]; then if [ ! -z "$AWS_S3_BUCKET_NAME" ] || [ ! -z "$AZURE_STORAGE_CONTAINER_NAME" ]; then grafana-backup restore $ARCHIVE_FILE; else grafana-backup restore _OUTPUT_/$ARCHIVE_FILE; fi else grafana-backup save; fi'

0 comments on commit 67f6294

Please sign in to comment.