Skip to content

Commit f7dfd70

Browse files
committed
Add slim version dockerfile
1 parent 67f6294 commit f7dfd70

File tree

3 files changed

+63
-26
lines changed

3 files changed

+63
-26
lines changed

.github/workflows/docker-image.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,30 @@ jobs:
2121

2222
- name: Extract metadata (tags, labels) for Docker
2323
id: meta
24-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
24+
uses: docker/metadata-action@v4
2525
with:
2626
images: ysde/docker-grafana-backup-tool
2727

28+
- name: Extract metadata (tags, labels) for Docker (Slim version)
29+
id: meta_slim
30+
uses: docker/metadata-action@v4
31+
with:
32+
images: ysde/docker-grafana-backup-tool
33+
flavor: |
34+
latest=auto
35+
suffix=-slim,onlatest=true
36+
2837
- name: Build and push Docker image
29-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
38+
uses: docker/build-push-action@v4
3039
with:
31-
context: .
3240
push: true
3341
tags: ${{ steps.meta.outputs.tags }}
3442
labels: ${{ steps.meta.outputs.labels }}
43+
44+
- name: Build and push Docker image slim version
45+
uses: docker/build-push-action@v4
46+
with:
47+
file: ./DockerfileSlim
48+
push: true
49+
tags: ${{ steps.meta_slim.outputs.tags }}
50+
labels: ${{ steps.meta_slim.outputs.labels }}

Dockerfile

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,20 @@ FROM alpine:latest
22

33
LABEL maintainer="ysde108@gmail.com"
44

5-
ARG UID=1337
6-
ARG GID=1337
75
ENV RESTORE false
86
ENV ARCHIVE_FILE ""
97

10-
ENV DEV_PACKAGES="\
11-
gcc \
12-
libc-dev \
13-
libffi-dev \
14-
py3-pip \
15-
python3-dev \
16-
"
8+
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
9+
&& apk --no-cache add python3-dev libffi-dev gcc libc-dev py3-pip py3-cffi py3-cryptography ca-certificates bash
1710

18-
ENV PACKAGES="\
19-
bash \
20-
ca-certificates \
21-
py3-cffi \
22-
py3-cryptography \
23-
py3-six \
24-
"
2511
WORKDIR /opt/grafana-backup-tool
2612
ADD . /opt/grafana-backup-tool
2713

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

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

38-
USER ${UID}
19+
RUN chown -R 1337:1337 /opt/grafana-backup-tool
20+
USER 1337
3921
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'

DockerfileSlim

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM alpine:latest
2+
3+
LABEL maintainer="ysde108@gmail.com"
4+
5+
ARG UID=1337
6+
ARG GID=1337
7+
ENV RESTORE false
8+
ENV ARCHIVE_FILE ""
9+
10+
ENV DEV_PACKAGES="\
11+
gcc \
12+
libc-dev \
13+
libffi-dev \
14+
py3-pip \
15+
python3-dev \
16+
"
17+
18+
ENV PACKAGES="\
19+
bash \
20+
ca-certificates \
21+
py3-cffi \
22+
py3-cryptography \
23+
py3-six \
24+
"
25+
WORKDIR /opt/grafana-backup-tool
26+
ADD . /opt/grafana-backup-tool
27+
28+
RUN chmod -R a+r /opt/grafana-backup-tool \
29+
&& find /opt/grafana-backup-tool -type d -print0 | xargs -0 chmod a+rx
30+
31+
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
32+
&& apk add --no-cache --virtual build-deps ${DEV_PACKAGES} \
33+
&& apk add --no-cache ${PACKAGES} \
34+
&& pip3 --no-cache-dir install . \
35+
&& chown -R ${UID}:${GID} /opt/grafana-backup-tool \
36+
&& apk del build-deps
37+
38+
USER ${UID}
39+
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 commit comments

Comments
 (0)