-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Add Dockerfile #81
base: main
Are you sure you want to change the base?
Conversation
Dockerfile
Outdated
RUN mkdir "/backup/backup" | ||
RUN mkdir "/backup/metrics" | ||
|
||
RUN pip install backup-github-org==1.0.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not hardcode version here. Use ARG
instead:
ARG VERSION
RUN pip install backup-github-org==${VERSION}
Dockerfile
Outdated
WORKDIR /backup | ||
|
||
ENV ACCESS_TOKEN="" | ||
ENV ORGANIZATION="" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about approach: image should contain only application, not environment. In other words image shouldn't contain any environments.
Your env variables are part of environment.
Dockerfile
Outdated
apt-get install -y git | ||
|
||
RUN mkdir "/backup/backup" | ||
RUN mkdir "/backup/metrics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put all RUN
into one
Dockerfile
Outdated
|
||
RUN pip install backup-github-org==1.0.4 | ||
|
||
ENTRYPOINT backup-github --all -t $ACCESS_TOKEN -o /backup/backup --metrics_path /backup/metrics/${ORGANIZATION}.prom $ORGANIZATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short: do not use entrypoint, use cmd. If you want to know more, google it - 'entrypoint vs cmd'.
If speak roughly - you don't need to care about how to run application inside container, you only need to pack it into image
Dockerfile
Outdated
ENV ACCESS_TOKEN="" | ||
ENV ORGANIZATION="" | ||
|
||
RUN apt-get update && apt-get upgrade -y && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean up apt cache at the end of dockerfile
Dockerfile
Outdated
ENV ACCESS_TOKEN="" | ||
ENV ORGANIZATION="" | ||
|
||
RUN apt-get update && apt-get upgrade -y && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use upgrade, it's antipattern
Dockerfile
Outdated
ENV ORGANIZATION="" | ||
|
||
RUN apt-get update && apt-get upgrade -y && \ | ||
apt-get install -y git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need git here?
Dockerfile
Outdated
|
||
ENTRYPOINT backup-github --all -t $ACCESS_TOKEN -o /backup/backup --metrics_path /backup/metrics/${ORGANIZATION}.prom $ORGANIZATION | ||
|
||
# Run command: docker run -rm -v .\backup:/backup/backup -v .\metrics:/backup/metrics -e ACCESS_TOKEN={} -e ORGANIZATION={} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally your Dockerfile should look like this:
FROM python:3.10
WORKDIR /backup
ARG VERSION
ENV DEBIAN_FRONTEND=noninteractive
RUN mkdir /backup/{backup,metrics} \
&& pip install backup-github-org==${VERSION}
CMD ["backup-github", "--help"]
Fixes: #77