Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder Dockerfile to take advantage of caching during build #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# COPYRIGHT SAVAGESOFTWARE,LLC, @ 2022, ALL RIGHTS RESERVED
# *********************************************************************
FROM node:lts-alpine
RUN apk update && apk add --no-cache tzdata

# IMAGE ARGUMENTS PASSED IN FROM BUILDER
ARG TARGETARCH
Expand All @@ -31,28 +32,15 @@ ARG BUILDVERSION
LABEL "com.example.vendor"="ACME Incorporated"
LABEL vendor="Savage Software, LLC"
LABEL maintainer="Robert Savage"
LABEL version="$VERSION"
LABEL description="Utility for scripting or scheduling scheduled backups for Portainer"
LABEL url="https://github.com/SavageSoftware/portainer-backup"
LABEL org.label-schema.schema-version="$VERSION"
LABEL org.label-schema.build-date="$BUILDDATE"
LABEL org.label-schema.name="savagesoftware/portainer-backup"
LABEL org.label-schema.description="Utility for scripting or scheduling scheduled backups for Portainer"
LABEL org.label-schema.url="https://github.com/SavageSoftware/portainer-backup"
LABEL org.label-schema.vcs-url="https://github.com/SavageSoftware/portainer-backup.git"
LABEL org.label-schema.vendor="Savage Software, LLC"
LABEL org.label-schema.version=$VERSION
LABEL org.label-schema.docker.cmd="docker run -it --rm --name portainer-backup --volume $PWD/backup:/backup savagesoftware/portainer-backup:latest backup"

# INSTALL ADDITIONAL IMAGE DEPENDENCIES AND COPY APPLICATION TO IMAGE
RUN apk update && apk add --no-cache tzdata
RUN mkdir -p /portainer-backup/src
COPY package.json /portainer-backup
COPY src/*.js /portainer-backup/src
WORKDIR /portainer-backup
VOLUME "/backup"
RUN npm install --silent

# DEFAULT ENV VARIABLE VALUES
ENV TZ="America/New_York"
ENV PORTAINER_BACKUP_URL="http://portainer:9000"
Expand All @@ -70,3 +58,19 @@ ENTRYPOINT [ "/usr/local/bin/node", "/portainer-backup/src/index.js" ]

# DEFAULT COMMAND (if none provided)
CMD ["schedule"]

VOLUME "/backup"

# PROVIDE IMAGE VERSION UNFORMATION
LABEL version="$VERSION"
LABEL org.label-schema.schema-version="$VERSION"
LABEL org.label-schema.version=$VERSION

# INSTALL ADDITIONAL IMAGE DEPENDENCIES AND COPY APPLICATION TO IMAGE
WORKDIR /portainer-backup
COPY package.json /portainer-backup/package.json
RUN npm install --silent

COPY src/*.js /portainer-backup/src/

LABEL org.label-schema.build-date="$BUILDDATE"