https://github.com/cisagov/skeleton-docker
A skeleton project for quickly getting a new cisagov Docker container started.
https://github.com/cisagov/skeleton-docker
docker skeleton
Last synced: 9 months ago
JSON representation
A skeleton project for quickly getting a new cisagov Docker container started.
- Host: GitHub
- URL: https://github.com/cisagov/skeleton-docker
- Owner: cisagov
- License: cc0-1.0
- Created: 2019-06-06T18:56:13.000Z (about 7 years ago)
- Default Branch: develop
- Last Pushed: 2025-09-18T18:42:24.000Z (10 months ago)
- Last Synced: 2025-09-18T20:22:08.491Z (10 months ago)
- Topics: docker, skeleton
- Language: Shell
- Size: 1010 KB
- Stars: 19
- Watchers: 4
- Forks: 10
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# skeleton-docker 💀🐳 #
[](https://github.com/cisagov/skeleton-docker/actions/workflows/build.yml)
[](https://github.com/cisagov/skeleton-docker/actions/workflows/codeql-analysis.yml)
## Docker Image ##
[](https://hub.docker.com/r/cisagov/example)
[](https://hub.docker.com/r/cisagov/example)
[](https://hub.docker.com/r/cisagov/example/tags)
This is a Docker skeleton project that can be used to quickly get a
new [cisagov](https://github.com/cisagov) GitHub Docker project
started. This skeleton project contains [licensing
information](LICENSE), as well as [pre-commit hooks](https://pre-commit.com)
and [GitHub Actions](https://github.com/features/actions) configurations
appropriate for Docker containers and the major languages that we use.
## Running ##
### Running with Docker ###
To run the `cisagov/example` image via Docker:
```console
docker run cisagov/example:0.2.2+build.1
```
### Running with Docker Compose ###
1. Create a `compose.yml` file similar to the one below to use [Docker Compose](https://docs.docker.com/compose/).
```yaml
---
name: skeleton-docker
services:
example:
environment:
- ECHO_MESSAGE="Hello from Docker Compose"
image: cisagov/example:0.2.2+build.1
ports:
- protocol: tcp
published: "8080"
target: 8080
volumes:
- source:
target: /var/log
type: bind
```
1. Start the container and detach:
```console
docker compose up --detach
```
## Using secrets with your container ##
This container also supports passing sensitive values via [Docker
secrets](https://docs.docker.com/engine/swarm/secrets/). Passing sensitive
values like your credentials can be more secure using secrets than using
environment variables. See the
[secrets](#secrets) section below for a table of all supported secret files.
1. To use secrets, create a `quote.txt` file containing the values you want set:
```text
Better lock it in your pocket.
```
1. Then add the secret to your `compose.yml` file:
```yaml
---
name: skeleton-docker
secrets:
quote_txt:
file: quote.txt
services:
example:
environment:
- ECHO_MESSAGE="Hello from Docker Compose"
image: cisagov/example:0.2.2+build.1
ports:
- protocol: tcp
published: "8080"
target: 8080
secrets:
- source: quote_txt
target: quote.txt
volumes:
- source:
target: /var/log
type: bind
```
## Updating your container ##
### Docker Compose ###
1. Pull the new image from Docker Hub:
```console
docker compose pull
```
1. Recreate the running container by following the [previous instructions](#running-with-docker-compose):
```console
docker compose up --detach
```
### Docker ###
1. Stop the running container:
```console
docker stop
```
1. Pull the new image:
```console
docker pull cisagov/example:0.2.2+build.1
```
1. Recreate and run the container by following the [previous instructions](#running-with-docker).
## Updating Python dependencies ##
This image uses [Pipenv] to manage Python dependencies using a [Pipfile](https://github.com/pypa/pipfile).
Both updating dependencies and changing the [Pipenv] configuration in `src/Pipfile`
will result in a modified `src/Pipfile.lock` file that should be committed to the
repository.
> [!WARNING]
> The `src/Pipfile.lock` as generated will fail `pre-commit` checks due to JSON formatting.
### Updating dependencies ###
If you want to update existing dependencies you would run the following command
in the `src/` subdirectory:
```console
pipenv lock
```
### Modifying dependencies ###
If you want to add or remove dependencies you would update the `src/Pipfile` file
and then update dependencies as you would above.
> [!NOTE]
> You should only specify packages that are direct requirements of
> your Docker configuration. Allow [Pipenv] to manage the dependencies
> of the specified packages.
## Image tags ##
The images of this container are tagged with [semantic
versions](https://semver.org) of the underlying example project that they
containerize. It is recommended that most users use a version tag (e.g.
`:0.2.2+build.1`).
| Image:tag | Description |
|-----------|-------------|
|`cisagov/example:0.2.2+build.1`| An exact release version. |
|`cisagov/example:0.2`| The most recent release matching the major and minor version numbers. |
|`cisagov/example:0`| The most recent release matching the major version number. |
|`cisagov/example:edge` | The most recent image built from a merge into the `develop` branch of this repository. |
|`cisagov/example:nightly` | A nightly build of the `develop` branch of this repository. |
|`cisagov/example:latest`| The most recent release image pushed to a container registry. Pulling an image using the `:latest` tag [should be avoided.](https://vsupalov.com/docker-latest-tag/) |
See the [tags tab](https://hub.docker.com/r/cisagov/example/tags) on Docker
Hub for a list of all the supported tags.
## Volumes ##
| Mount point | Purpose |
|-------------|----------------|
| `/var/log` | Log storage |
## Ports ##
The following ports are exposed by this container:
| Port | Purpose |
|------|----------------|
| 8080 | Example only; nothing is actually listening on the port |
The sample [Docker composition](compose.yml) publishes the
exposed port at 8080.
## Environment variables ##
### Required ###
There are no required environment variables.
### Optional ###
| Name | Purpose | Default |
|-------|---------|---------|
| `ECHO_MESSAGE` | Sets the message echoed by this container. | `Hello World from Dockerfile` |
## Secrets ##
| Filename | Purpose |
|--------------|---------|
| `quote.txt` | Replaces the secret stored in the example library's package data. |
## Building from source ##
Build the image locally using this git repository as the [build context](https://docs.docker.com/engine/reference/commandline/build/#git-repositories):
```console
docker build \
--tag cisagov/example:0.2.2+build.1 \
https://github.com/cisagov/example.git#develop
```
## Cross-platform builds ##
To create images that are compatible with other platforms, you can use the
[`buildx`](https://docs.docker.com/buildx/working-with-buildx/) feature of
Docker:
1. Copy the project to your machine using the `Code` button above
or the command line:
```console
git clone https://github.com/cisagov/example.git
cd example
```
1. Create the `Dockerfile-x` file with `buildx` platform support:
```console
./buildx-dockerfile.sh
```
1. Build the image using `buildx`:
```console
docker buildx build \
--file Dockerfile-x \
--platform linux/amd64 \
--output type=docker \
--tag cisagov/example:0.2.2+build.1 .
```
## New repositories from a skeleton ##
Please see our [Project Setup guide](https://github.com/cisagov/development-guide/tree/develop/project_setup)
for step-by-step instructions on how to start a new repository from
a skeleton. This will save you time and effort when configuring a
new repository!
## Contributing ##
We welcome contributions! Please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for
details.
## License ##
This project is in the worldwide [public domain](LICENSE).
This project is in the public domain within the United States, and
copyright and related rights in the work worldwide are waived through
the [CC0 1.0 Universal public domain
dedication](https://creativecommons.org/publicdomain/zero/1.0/).
All contributions to this project will be released under the CC0
dedication. By submitting a pull request, you are agreeing to comply
with this waiver of copyright interest.
[Pipenv]: https://pypi.org/project/pipenv/