Dockerfile best practices #3

Closed
opened 2024-01-12 20:05:21 +01:00 by florian · 0 comments
Owner

The Dockerfile, albeit working has a few issues we should address, either for security, consistency or just for brownie points.

Security

  • We should add a non-root user to the Dockerfile and run the binary with the permissions of that user.

  • While not strictly speaking an issue now, we should use good practices from the beginning and copy files into the stages and between the stages explicitly instead of just plainly copying everything around with COPY . ..

    This also has the brownie points benefit of allowing better caching later down the line I think.

Consistency

  • Our native binaries are named gitea-account-bot-$VERSION-$ARCH. So there is no reason why would be diverging from that within the Docker images.

    ⚠️ This is a breaking change for users who are using the Docker image with a custom commandline and
    explicitly refer to the executable directly.

The Dockerfile, albeit working has a few issues we should address, either for security, consistency or just for brownie points. ### Security * We should add a non-root user to the Dockerfile and run the binary with the permissions of that user. * While not strictly speaking an issue now, we should use good practices from the beginning and copy files into the stages and between the stages explicitly instead of just plainly copying everything around with `COPY . .`. This also has the brownie points benefit of allowing better caching later down the line I think. ### Consistency * Our native binaries are named `gitea-account-bot-$VERSION-$ARCH`. So there is no reason why would be diverging from that within the Docker images. ⚠️ **This is a breaking change for users who are using the Docker image with a custom commandline and explicitly refer to the executable directly.**
florian added the
Kind/Bug
Kind/Security
Kind/Breaking
Priority
Medium
labels 2024-01-12 20:05:21 +01:00
florian self-assigned this 2024-01-12 20:05:21 +01:00
florian added reference main 2024-01-12 20:05:39 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: beisel.org/gitea-register-account-bot#3
No description provided.