- add more detailed default readme
This commit is contained in:
parent
e0d80087b9
commit
8d09da2772
96
README.md
96
README.md
@ -1,5 +1,95 @@
|
|||||||
# Docker Image Build: almalinux template
|
# Docker Image Build: Almalinux Template
|
||||||
|
|
||||||
[](https://droneci.query.consul/unkin/docker-almalinux-base)
|
|
||||||
|
|
||||||
This project provides a reproducible Docker image build process for `almalinux:8.10`, with custom YUM repository configurations and package installations. The build is automated using a `Makefile` and managed via CI tasks to ensure consistent and reliable Docker image builds.
|
This project provides a reproducible Docker image build process for `almalinux:8.10`, with custom YUM repository configurations and package installations. The build is automated using a `Makefile` and managed via CI tasks to ensure consistent and reliable Docker image builds.
|
||||||
|
|
||||||
|
## Makefile Overview
|
||||||
|
|
||||||
|
The `Makefile` provides several targets to automate building, tagging, and pushing Docker images. The Docker image is tagged with the current Git commit hash, the current date, and a `latest` tag for easy reference.
|
||||||
|
|
||||||
|
## Makefile Targets
|
||||||
|
|
||||||
|
### Build the Docker Image
|
||||||
|
|
||||||
|
To build the Docker image without tags:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
|
This will use the `docker build` command with `--network=host` to build the image with the name `git.query.consul/unkin/almalinux8-template`.
|
||||||
|
|
||||||
|
### Tag the Docker Image
|
||||||
|
|
||||||
|
To tag the Docker image with the Git commit hash, the current date, and a `latest` tag:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make tag
|
||||||
|
```
|
||||||
|
|
||||||
|
This will add three tags to the image:
|
||||||
|
- `git.query.consul/unkin/almalinux8-template:<GIT_COMMIT>`
|
||||||
|
- `git.query.consul/unkin/almalinux8-template:<DATE_TAG>`
|
||||||
|
- `git.query.consul/unkin/almalinux8-template:latest`
|
||||||
|
|
||||||
|
### Push the Docker Image
|
||||||
|
|
||||||
|
To push the tagged Docker images to the registry:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make push
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**: The `push` command is currently commented out for safety. To enable pushing, remove the comment (`#`) from the `docker push` lines in the `push` target.
|
||||||
|
|
||||||
|
### Clean Up
|
||||||
|
|
||||||
|
To clean up any dangling Docker images:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make clean
|
||||||
|
```
|
||||||
|
|
||||||
|
This will remove any dangling (unused) Docker images using `docker image prune -f`.
|
||||||
|
|
||||||
|
### Default Target
|
||||||
|
|
||||||
|
The default target is `build`. So running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
is equivalent to running `make build`.
|
||||||
|
|
||||||
|
## Development and Testing
|
||||||
|
|
||||||
|
To test or develop with this `Makefile`, follow these steps:
|
||||||
|
|
||||||
|
1. **Clone the repository** and navigate to the project directory:
|
||||||
|
```bash
|
||||||
|
git clone https://git.query.consul/unkin/docker-template.git
|
||||||
|
cd docker-template
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Build the Docker image** using the `build` target:
|
||||||
|
```bash
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Tag the image** with the commit hash, date, and latest tag:
|
||||||
|
```bash
|
||||||
|
make tag
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **(Optional)** Modify the `push` target to enable pushing the image to your Docker registry:
|
||||||
|
Uncomment the lines in the `push` target:
|
||||||
|
```makefile
|
||||||
|
docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT)
|
||||||
|
docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG)
|
||||||
|
docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Test your changes** locally by running the `clean` target:
|
||||||
|
```bash
|
||||||
|
make clean
|
||||||
|
```
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user