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
* 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).
80
82
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`
0 commit comments