Dockerfiles
Dockerfiles for various projects
- Documentation: https://entelecheia.github.io/dockerfiles
- GitHub: https://github.com/entelecheia/dockerfiles
This repository contains Dockerfiles for various projects. Fork this repository to create your own Dockerfiles.
Usage
There are a few helper scripts that can be used to simplify the process of building and running Docker containers. These scripts are installed in the process of setting up dotfiles and can be found in the .local/bin directory.
dockerfiles-clone Script
The dockerfiles-clone script is designed to help you clone or update the Dockerfiles repository on your system. To use this script, follow these steps:
- Configure Environment Variables (optional):
If you have specific values for
DOCKERFILES_REPOorDOCKERFILES_DIR, you can set these environment variables before running the script. Otherwise, the script will use the default values specified in the script.
export DOCKERFILES_REPO="https://github.com/username/dockerfiles.git"
export DOCKERFILES_DIR="/path/to/dockerfiles"
- Run the Script:
Execute the
dockerfiles-clonescript:
This script will perform the following tasks:
- Check if the Dockerfiles repository is set. If not, it will display a message and exit.
- If the Dockerfiles directory exists, it will prompt you to remove the existing directory.
- If you choose to remove the existing directory, it will delete the directory and proceed to clone the repository.
- If you choose not to remove the existing directory, it will display a message and exit.
- If the Dockerfiles directory does not exist, it will clone the Dockerfiles repository to the specified directory.
After running the dockerfiles-clone script, your Dockerfiles repository will be cloned or updated, and you can start using the Dockerfiles on your system.
dockerfiles-pull Script
The dockerfiles-pull script helps you update the Dockerfiles repository on your system. To use this script, follow these steps:
- Configure Environment Variables (optional):
If you have specific values for
DOCKERFILES_REPOorDOCKERFILES_DIR, you can set these environment variables before running the script. Otherwise, the script will use the default values specified in the script.
export DOCKERFILES_REPO="https://github.com/username/dockerfiles.git"
export DOCKERFILES_DIR="/path/to/dockerfiles"
- Run the Script:
Execute the
dockerfiles-pullscript:
This script will perform the following tasks:
- Check if the Dockerfiles directory exists.
- If the directory exists and is a valid Git repository, it will update the Dockerfiles repository using
git pull --rebase --autostash.
After running the dockerfiles-pull script, your Dockerfiles repository will be updated, and you can continue using the latest Dockerfiles on your system.
dockerfiles-sync Script
The dockerfiles-sync script helps you synchronize Dockerfiles between your project directory and the shared Dockerfiles directory. To use this script, follow these steps:
- Configure Environment Variables (optional):
If you have specific values for
WORKSPACE_PROJECT_DIRorDOCKERFILES_SHARE_DIR, you can set these environment variables before running the script. Otherwise, the script will use the default values specified in the script.
export WORKSPACE_PROJECT_DIR="/path/to/workspace/project/directory"
export DOCKERFILES_SHARE_DIR="/path/to/dockerfiles/share/directory"
- Run the Script:
Execute the
dockerfiles-syncscript with the desired options:
dockerfiles-sync [DOCKER_NAME] [--from-project] [--project-directory PROJECT_DIR] [--dockerfiles-directory DOCKERFILES_DIR] [-h|--help]
Available options:
DOCKER_NAME: Specify the name of a specific Docker project to sync.--from-project: Sync Dockerfiles from the project directory to the shared Dockerfiles directory.--project-directory PROJECT_DIR: Set the project directory path.--dockerfiles-directory DOCKERFILES_DIR: Set the shared Dockerfiles directory path.-h|--help: Display usage information.
Examples:
-
Sync all Dockerfiles from the shared Dockerfiles directory to the workspace project directory:
-
Sync a specific Dockerfile from the shared Dockerfiles directory to the workspace project directory:
-
Sync all Dockerfiles from the workspace project directory to the shared Dockerfiles directory:
-
Sync a specific Dockerfile from the workspace project directory to the shared Dockerfiles directory:
After running the dockerfiles-sync script, your Dockerfiles will be synchronized between the specified directories.
The dk-compose script is a convenient wrapper for managing Docker Compose projects. To use the script, follow the usage format below:
dk-compose Script
Usage: dk-compose COMMAND DOCKER_NAME [-t|--tag TAG] [--from-project] [--project-directory PROJECT_DIR] [--dockerfiles-directory DOCKERFILES_DIR] [-c|--compose-filename COMPOSE_FILENAME] [-e|--env-filename ENV_FILENAME] [-v|--version VERSION] [-l|--latest] [--push] [-n|--name CONTAINER_NAME] [--network DOCKER_NETWORK_NAME] [-u|--username USERNAME] [-h|--help]
COMMAND - One of the following Docker Compose commands:
build: Build the Docker services defined in the Compose file.run: Run a one-off command on a service.up: Create and start the containers defined in the Compose file.down: Stop and remove containers, networks, and volumes defined in the Compose file.
DOCKER_NAME - The name of the Docker project.
Options:
-
-t, --tag TAG: Specify a tag to use for the Docker Compose file and environment file. The script will look for files nameddocker-compose-TAG.yamlanddocker.TAG.env, whereTAGis the provided tag. -
--from-project: Use the project directory as the source of the Docker Compose files instead of the default Dockerfiles directory. -
--project-directory PROJECT_DIR: Provide a custom path to the project directory. If not specified, the script will use the default project directory. -
--dockerfiles-directory DOCKERFILES_DIR: Provide a custom path to the directory containing the Dockerfiles. If not specified, the script will use the default Dockerfiles directory. -
-c, --compose-filename COMPOSE_FILENAME: Specify a custom Docker Compose file name. If not specified, the script will use the defaultdocker-compose.yamlordocker-compose-TAG.yamlbased on the provided tag. -
-e, --env-filename ENV_FILENAME: Specify a custom environment file name. If not specified, the script will use the defaultdocker.envordocker.TAG.envbased on the provided tag. -
-v, --version VERSION: Specify the version of the Docker image to use. This will be set as theVERSIONenvironment variable for the Docker Compose process. -
-l, --latest: Use the latest version of the Docker image. Sets theVERSIONenvironment variable to "latest". -
--push: After successfully building the Docker image, push the image to a remote repository. -
-n, --name CONTAINER_NAME: Specify a custom name for the container that will be created. -
--network DOCKER_NETWORK_NAME: Specify the name of the Docker network to use or create. If the network does not exist, the script will create it. -
-u, --username USERNAME: Specify the username to use for the Docker image. If not provided, the script will use the default username from the configuration. -
-h, --help: Display the usage information for the script.
Examples:
- Build a Docker project named
my_projectwith tagdev:
- Run a one-off command (
some_command) on themy_serviceservice in themy_projectDocker project:
- Start the containers defined in the
my_projectDocker project with tagprod:
- Stop and remove the containers, networks, and volumes defined in the
my_projectDocker project with tagprod:
Remember that the dk-compose script should be executable and located in a directory included in the PATH variable (e.g., .local/bin).
Changelog
See the CHANGELOG for more information.
Contributing
Contributions are welcome! Please see the contributing guidelines for more information.
License
This project is released under the MIT License.
Check out the usage section for further information.
Note
This project is under active development.