You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Managing the Project with Docker & GitHub Actions (CI/CD)
4
+
5
+
This project builds and pushes a multi-arch Docker image to [GHCR](https://github.com/orgs/refactor-group/packages) and triggers a build workflow on GitHub automatically on pushes to branches with open pull requests.
6
+
7
+
**Key Steps:**
8
+
9
+
1.**Develop Your Changes:**
10
+
- Work on your feature or fix in your branch.
11
+
2.**Open a Pull Request:**
12
+
- When you open a PR, GitHub Actions triggers the build workflow.
13
+
3.**Automated Build & Push:**
14
+
- The workflow builds a multi-arch Docker image and pushes it to GHCR.
15
+
- Verify the build status in GitHub Actions.
16
+
- The images are named as follows: `ghcr.io/refactor-group/refactor-platform-fe/<branch>:latest`
17
+
4.**Local Testing (Optional):**
18
+
- For local Docker testing, note that the Docker Compose file and environment variables are maintained in the backend repository. Make sure you have access to that repo for configuration details.
19
+
20
+
---
21
+
22
+
## Manual Docker Image Management
23
+
24
+
### If you plan on working with the Docker Image Locally as well the following section acts as a quickstart guide for managing the Docker images manually
25
+
26
+
#### Prerequisites
27
+
28
+
- Before running any Docker commands, ensure you are logged into GHCR using your GitHub personal access token (PAT):
-`<branch>` is the name of the branch, with underscores converted to dashes.
47
+
-`latest` is the tag.
48
+
49
+
**Useful Commands:**
50
+
51
+
```bash
52
+
# Docker Buildx: Enhanced Image Management
53
+
54
+
# 1. Inspect Docker Buildx
55
+
docker buildx version # Verify Docker Buildx is installed
56
+
57
+
# 2. Create a new builder instance (if needed)
58
+
docker buildx create --name mybuilder --driver docker-container # Creates a builder instance named 'mybuilder' using the docker-container driver
59
+
60
+
# 3. Use the builder
61
+
docker buildx use mybuilder # Sets 'mybuilder' as the current builder
62
+
63
+
# 4. Inspect the builder
64
+
docker buildx inspect --bootstrap # Displays details and ensures the builder is running
65
+
66
+
# 5. Login to GHCR
67
+
docker login ghcr.io -u <your_github_username> -p <your_PAT># Authenticates with GitHub Container Registry using your username and PAT
68
+
69
+
# 6. Build the image for multiple architectures and push to registry
70
+
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/refactor-group/refactor-platform-fe:<branch> --push .# Builds for specified architectures and pushes to GHCR
71
+
72
+
# 7. Build the image for multiple architectures and load to local docker daemon
73
+
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/refactor-group/refactor-platform-fe:<branch> --load .# Builds for specified architectures and loads to local docker daemon
74
+
75
+
# 8. Tag the image
76
+
docker tag ghcr.io/refactor-group/refactor-platform-fe:<branch> ghcr.io/refactor-group/refactor-platform-fe:<branch>:latest # Creates an additional tag 'latest' for the image
77
+
78
+
# 9. Push the image
79
+
docker push ghcr.io/refactor-group/refactor-platform-fe:<branch>:latest # Uploads the image to the container registry
80
+
81
+
# 10. Pull the image
82
+
docker pull ghcr.io/refactor-group/refactor-platform-fe:<branch>:latest # Downloads the image from the container registry
83
+
84
+
# 11. Run the image
85
+
docker run -p 3000:3000 ghcr.io/refactor-group/refactor-platform-fe:<branch>:latest # Starts a container from the image, mapping port 3000
86
+
87
+
# 12. Inspect the image
88
+
docker inspect ghcr.io/refactor-group/refactor-platform-fe:<branch>:latest # Shows detailed information about the image
89
+
90
+
# 13. Remove the image
91
+
docker rmi ghcr.io/refactor-group/refactor-platform-fe:<branch>:latest # Deletes the image from the local machine
92
+
```
93
+
94
+
### Important Notes
95
+
96
+
- Always use the `latest` tag for the most recent version (it defaults to `latest`)
97
+
- Ensure your branch is up to date with the main branch before opening a PR
98
+
- For backend-specific configuration (Docker Compose & env vars), refer to the backend repository documentation
0 commit comments