Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Example Dockerfile for docker-template
FROM alpine:3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For reproducible builds, it's a best practice to pin the base image to a specific version instead of using a floating tag like :3. This prevents unexpected changes or build failures when the base image is updated.

Consider using a more specific tag, for example alpine:3.19.

FROM alpine:3.19


# Set a working directory
WORKDIR /app

# Default command prints a message
CMD ["sh", "-c", "echo Hello from docker-template"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Running containers as a non-root user is a critical security best practice. The container will run as the root user by default, which should be avoided to limit the potential blast radius of a vulnerability.

Please add instructions to create a non-root user and switch to it before the CMD instruction. For example:

RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# docker-template
A template for maintaining docker images using github Actions to automate Packages
A template for maintaining docker images using GitHub Actions to automate Packages.

This repository includes a simple example `Dockerfile` and accompanying `docker-compose.yml` to demonstrate how you might build and run a container.

## Build the image
```sh
docker build -t docker-template .
```

## Run with Docker Compose
```sh
docker compose up

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's common to run services in the background using detached mode (-d). Additionally, it would be very helpful for users to know the command to stop and clean up the created resources.

Consider also mentioning docker compose down in the instructions.

Suggested change
docker compose up
docker compose up -d

```
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: '3'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The top-level version property is deprecated in modern Docker Compose files and is no longer necessary. You can safely remove this line.

services:
app:
build: .
container_name: docker-template-example

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Hardcoding container_name is generally considered an anti-pattern in Docker Compose. It prevents you from scaling a service (e.g., docker compose up --scale app=3), as container names must be unique.

It's better to let Docker Compose manage container names automatically. I recommend removing this line to follow best practices and allow for scalability.