From 7928f1ecb4a2d68f1b8b19284b11f0001e29516a Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Tue, 7 May 2024 13:30:42 -0600 Subject: [PATCH] Update Docker & Kubernetes/Docker/Custom Containers/Container Development.md --- .../Container Development.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Docker & Kubernetes/Docker/Custom Containers/Container Development.md b/Docker & Kubernetes/Docker/Custom Containers/Container Development.md index af01c05..e1222fe 100644 --- a/Docker & Kubernetes/Docker/Custom Containers/Container Development.md +++ b/Docker & Kubernetes/Docker/Custom Containers/Container Development.md @@ -13,3 +13,57 @@ You will need to locate and install the `Dev Containers`, `Docker`, and `WSL` ex !!! warning You need to have Docker Desktop "Engine" running whenever working with containers, as it is necessary to build the images. VSCode will complain if it is not running. +## Add Gitea Container Registry +At this point, we need to add a registry to Visual Studio Code so it can proceed with pulling down the repository data. + +- Click the Docker icon on the left-hand toolbar +- Under "**Registries**", click "**Connect Registry...**" +- In the dropdown menu that appears, click "**Generic Registry V2**" +- Enter `https://git.bunny-lab.io/container-registry` + - Registry Username: `nicole.rappe` + - Registry Password or Personal Access Token: `Personal Access API Token You Generated in Gitea` +- You will now see a sub-listing named "**Generic Registry V2**" +- If you click the dropdown, you will see "**https://git.bunny-lab.io/container-registry**" + - Under this section, you will see any containers in the registry that you have access to, in this case, you will see `container-registry/git-repo-updater` + +## Add Source Control Repository +Now it is time to pull down the repository where the container's core elements are stored on Gitea. + +- Click the "**Source Control**" button on the left-hand menu then click the "**Clone Repository**" button +- Enter `https://git.bunny-lab.io/container-registry/git-repo-updater.git` +- Click the dropdown menu option "**Clone from URL**" then choose a location to locally store the repository on your computer +- When prompted with "**Would you like to open the cloned repository**", click the "**Open**" button + +## Making Changes +You will be presented with four files in this specific repository. `.env`, `docker-compose.yml`, `Dockerfile`, and `repo_watcher.sh` + +- `.env` is the environment variables passed to the container to tell it which ntfy server to talk to, which credentials to use with Gitea, and which repositories to download and push into production servers +- `docker-compose.yml` is an example docker-compose file that can be used in Portainer to deploy the server along with the contents of the `.env` file +- `Dockerfile` is the base of the container, telling docker what operating system to use and how to start the script in the container +- `repo_watcher.sh` is the script called by the `Dockerfile` which loops checking for updates in Gitea repositories that were configured in the `.env` file + +### Push to Repository +When you make any changes, you will need to first commit them to the repository + +- Save all of the edited files +- Click the "**Source Control**" button in the toolbar +- Write a message about what you changed in the commit description field +- Click the "**Commit**" button +- Click the "**Sync Changes**" button that appears + - You may be presented with various dialogs, just click the equivalant of "**Yes/OK**" to each of them + +### Build the Dockerfile +At this point, we need to build the dockerfile, which takes all of the changes and packages it into a container image + +- Navigate back to the file explorer inside of Visual Studio Code +- Right-click the `Dockerfile`, then click "**Build Image...**" +- In the "Tag Image As..." window, type in `git.bunny-lab.io/container-registry/git-repo-updater:latest` +- When you navigate back to the Docker menu, you will see a new image appear under the "**Images**" section + - You should see something similar to "Latest - X Seconds Ago` indicating this is the image you just built + - Delete the older image(s) by right-clicking on them and selecting "**Remove...**" + - Push the image to the container registry in Gitea by right-clicking the latest image, and selecting "**Push...**" + - In the dropdown menu that appears, enter `git.bunny-lab.io/container-registry/git-repo-updater:latest` + - You can confirm if it was successful by navigating to the [Gitea Container Webpage](https://git.bunny-lab.io/container-registry/-/packages/container/git-repo-updater/latest) and seeing if it says "**Published Now**" or "**Published 1 Minute Ago**" + +## Deploy the Container +You can now use the `.env` file along with the `docker-compose.yml` file inside of Portainer to deploy a stack using the container you just built / updated. \ No newline at end of file