Skip to content

Commit 4b59cd6

Browse files
committed
Update README
1 parent f590977 commit 4b59cd6

1 file changed

Lines changed: 74 additions & 55 deletions

File tree

README.md

Lines changed: 74 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
## 1. OVERVIEW
1+
## 1. Overview
22
**Project Structure**
33
```
44
includes/ → Header files (.h, .hpp)
55
src/ → Source files (.cpp)
66
tests/ → GoogleTest test cases
77
```
8-
## 2. DEPENDENCIES
8+
## 2. Dependencies
99
Make sure the following tools are installed before building the project:
1010
- **g++ / gcc**
1111
- **CMake**
@@ -14,68 +14,87 @@ Make sure the following tools are installed before building the project:
1414
- **cppcheck** (for static analysis)
1515
- **Optional:** Install `clang-format` to format C++ code.
1616

17-
Linux
17+
**Linux**
1818
```bash
1919
sudo apt install clang-format
2020
find . -regex '.*\.\(cpp\|h\|hpp\)' -exec clang-format -i {} \;
2121
```
22-
Windows
22+
**Windows**
2323
```bash
2424
# Install clang-format via Chocolatey
2525
choco install clang-format
2626

2727
# Apply clang-format recursively to .cpp, .h, .hpp files
2828
Get-ChildItem -Recurse -Include *.cpp, *.h, *.hpp | ForEach-Object { clang-format -i $_.FullName }
2929
```
30-
## 3. SETUP
31-
* Setup the Local Test Environment
32-
* 1.Using your own Ubuntu system
33-
* Install `gcc`, `cmake`, `git`, and `pthread` (Skip this step if you already install)
34-
```
35-
$ sudo apt-get update
36-
$ sudo apt-get install g++
37-
$ sudo apt-get install lcov
38-
$ sudo apt-get install cmake
39-
$ sudo apt-get install git
40-
$ sudo apt-get install cppcheck
41-
```
42-
* Build the application and the tests
43-
```
44-
$ cd build
45-
$ cmake ..
46-
$ cmake --build .
47-
```
48-
* Run the application and the test
49-
```
50-
$ ./cpp_lab_project
51-
$ ./cpp_lab_project_test
52-
```
53-
* (Optional) Run static analysis
54-
```
55-
$ sudo apt-get install cppcheck
56-
$ cppcheck "folder" / "file"
57-
```
58-
* 2.Using **Docker**
59-
* Build the Docker image
60-
```
61-
docker build --tag sample-ci-cpp .
62-
```
63-
* Run an interactive container
64-
```
65-
docker run -it sample-ci-cpp:latest /bin/bash
66-
```
67-
* Inspect the environment
68-
```
69-
printenv
70-
```
71-
* *Notes:*
72-
* Use the -t or --tag flag to set the name of the image to be created. (the full name is actually sample-ci-cpp:latest, since latest is the default tag)
73-
* Opening an interactive shell inside your Docker container to explore, test, or debug the environment built from your image.
74-
* docker run to start a new container.
75-
* -it → run it interactively:
76-
* -i = keep STDIN open (so you can type commands)
77-
* -t = allocate a terminal (TTY)
78-
* sample-ci-cpp:latest → the image you built earlier.
79-
* /bin/bash → the command to execute inside the container (opens a Bash shell).
30+
## 3. Setup
31+
### 3.1. Setup the Local Test Environment
32+
- **Ubuntu system**
33+
* Install `gcc`, `cmake`, `git`, and `pthread` (Skip this step if you already install)
34+
```
35+
$ sudo apt-get update
36+
$ sudo apt-get install g++
37+
$ sudo apt-get install lcov
38+
$ sudo apt-get install cmake
39+
$ sudo apt-get install git
40+
$ sudo apt-get install cppcheck
41+
```
42+
* Build the application and the tests
43+
```
44+
$ cd build
45+
$ cmake ..
46+
$ cmake --build .
47+
```
48+
* Run the application and the test
49+
```
50+
$ ./cpp_lab_project
51+
$ ./cpp_lab_project_test
52+
```
53+
* (Optional) Run static analysis
54+
```
55+
$ sudo apt-get install cppcheck
56+
$ cppcheck "folder" / "file"
57+
```
58+
- **Docker**
59+
* Update `Dockerfile`
60+
* Build the Docker image
61+
```
62+
$ cd build
63+
$ docker build --tag cpp-lab .
64+
```
65+
* Run an interactive container
66+
```
67+
$ docker run -it cpp-lab:latest /bin/bash
68+
```
69+
* Inspect the environment
70+
```
71+
$ printenv
72+
```
73+
* *Notes:*
74+
* Use the `-t` or `--tag` flag to set the name of the image to be created. (the full name is actually `cpp-lab:latest`, since latest is the default tag)
75+
* Opening an interactive shell inside your Docker container to explore, test, or debug the environment built from your image.
76+
* docker run to start a new container.
77+
* `-it`: run it interactively:
78+
* `-i`: keep STDIN open (so you can type commands)
79+
* `-t`: allocate a terminal (TTY)
80+
* `cpp-lab:latest`: the image you built earlier.
81+
* `/bin/bash`: the command to execute inside the container (opens a Bash shell).
8082
81-
## 4. DOCUMENTATIONS
83+
## 5. Update Docker Image
84+
```bash
85+
# Navigate to the project that contain your Dockerfile
86+
cd cpp-lab
87+
88+
# Build the project by running the following command, swapping out DOCKER_USERNAME with your username.
89+
docker build -t DOCKER_USERNAME/cpp-lab .
90+
91+
# Verify the image exists locally
92+
docker image ls
93+
94+
# To push the image
95+
docker push DOCKER_USERNAME/cpp-lab
96+
```
97+
98+
## 6. TROUBLESHOOTING
99+
1. `push access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed`
100+
=> docker login / Docker Desktop login

0 commit comments

Comments
 (0)