Skip to content

Conversation

@Karina5005
Copy link
Member

@Karina5005 Karina5005 commented Oct 16, 2023

Fixes: #77

@Karina5005 Karina5005 requested a review from bissquit October 16, 2023 06:58
Dockerfile Outdated
RUN mkdir "/backup/backup"
RUN mkdir "/backup/metrics"

RUN pip install backup-github-org==1.0.4
Copy link
Member

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=""
Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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 && \
Copy link
Member

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 && \
Copy link
Member

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
Copy link
Member

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={} No newline at end of file
Copy link
Member

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"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker container

3 participants