-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a more compact docker image (remove dev packages from image) (#…
…196)
- Loading branch information
Showing
1 changed file
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' |