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
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/circleci-gcp/circleci-arm64-cloud-demo.md
+88-51Lines changed: 88 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,80 +6,97 @@ weight: 8
6
6
layout: learningpathall
7
7
---
8
8
9
-
## Deploying a Cloud-Native Arm64 Node.js App using self-hosted CircleCI Runner on GCP
9
+
## Deploying a Cloud-Native Arm64 Node.js App Using a Self-Hosted CircleCI Runner on GCP
10
10
11
-
This guide walks through building and testing a simple **Node.js web app** using a **self-hosted CircleCI Arm64 runner**on a **GCP SUSE Arm64 VM**.
11
+
This section demonstrates how to build and test a simple Node.js web application using a self-hosted CircleCI runner running on a Google Cloud C4A (Axion Arm64) SUSE Linux virtual machine.
12
12
13
+
You’ll configure Docker on the VM so that CircleCI jobs can build, test, and run containerized applications directly in your Arm64 environment, ideal for cloud-native development and CI/CD workflows targeting Arm architecture.
13
14
14
-
### Install and Configure Docker
15
-
Ensure Docker is installed, started, and accessible by both your user and the CircleCI runner service.
16
15
17
-
-**Install Docker**: Refresh your package manager and install Docker on your system.
18
-
-**Enable Docker Service**: Ensure Docker starts on boot and is running.
19
-
-**Add User to Docker Group**: Add both your user and the CircleCI runner to the Docker group to grant access.
16
+
### Install and Configure Docker
17
+
Ensure Docker is installed, enabled, and accessible by both your local user and the CircleCI runner service.
20
18
21
-
```console
19
+
1. Install Docker
20
+
Refresh your package manager and install Docker on your system:
21
+
```bash
22
22
sudo zypper refresh
23
23
sudo zypper install docker
24
+
```
25
+
2. Enable and start Docker service
26
+
Set Docker to start automatically at boot and verify it’s running:
27
+
```bash
24
28
sudo systemctl enable docker
25
29
sudo systemctl start docker
26
30
sudo systemctl status docker
31
+
```
32
+
3. Grant Docker access to users
33
+
Add both your current user and the circleci system user to the Docker group so they can run Docker commands without sudo:
34
+
```bash
27
35
sudo usermod -aG docker $USER
28
36
sudo usermod -aG docker circleci
29
37
```
30
38
### Validate Docker access
31
-
This command switches to the CircleCI user and checks if Docker is working correctly.
39
+
After installing Docker and adding the circleci user to the Docker group, verify that the CircleCI runner user can access Docker without requiring elevated privileges.
32
40
33
-
```console
41
+
Run the following commands:
42
+
```bash
34
43
sudo -u circleci -i
35
44
docker ps
36
45
exit
37
46
```
38
47
39
48
### Verify Docker Permissions
40
-
Check Docker socket permissions and ensure that the CircleCI runner is active and running.
49
+
Now, confirm that Docker’s socket permissions and the CircleCI runner service are both configured correctly.
41
50
42
-
```console
51
+
```bash
43
52
ls -l /var/run/docker.sock
44
53
ps -aux | grep circleci-runner
45
54
```
46
-
-**Check Docker Socket Permissions**: This command ensures the Docker socket is accessible.
47
-
-**Verify CircleCI Runner Process**: Confirm the CircleCI runner service is active and running.
55
+
These commands ensure that the Docker socket is accessible and the CircleCI runner service is active and running.
56
+
57
+
Once both checks pass, your environment is ready to build and run container-based pipelines with CircleCI on SUSE Arm64.
48
58
49
-
### **Install Node.js and npm**
59
+
### Install Node.js and npm
50
60
51
-
Before proceeding with the app setup, please make sure **Node.js** and **npm** (Node.js package manager) are installed on the VM, as they are required to run your Node.js app.
61
+
Before setting up the sample application, ensure that `Node.js` and its package manager`npm`are installed on your SUSE Arm64 VM. Both are required to run, build, and test the `Node.js` web application within your CircleCI pipeline.
52
62
53
-
-**Install Node.js**: Use the official Node.js package for Arm64 architecture.
54
-
-**Install npm**: npm is automatically installed when Node.js is installed.
63
+
- Install Node.js: Install the official Node.js package built for the Arm64 architecture.
64
+
- Install npm: npm (Node Package Manager) is bundled with Node.js but can also be explicitly installed or upgraded if needed.
55
65
56
66
```console
57
67
sudo zypper install nodejs
58
68
sudo zypper install npm
59
69
```
70
+
Next, you’ll create the demo project and prepare its CircleCI configuration to run jobs using your self-hosted Arm64 runner.
71
+
60
72
### Create a repository for your example code
61
-
First, install GitHub CLI:
73
+
To store and manage your Node.js demo application, you’ll create a new GitHub repository using the GitHub CLI.
74
+
75
+
1. Install the GitHub CLI
76
+
The GitHub CLI (gh) lets you manage repositories, issues, and pull requests directly from your terminal.
62
77
63
78
```bash
64
-
sudo zypper install gh
79
+
sudo zypper install -y gh
65
80
```
66
-
Authenticate:
81
+
2. Authenticate with GitHub
82
+
Run the following command to connect the CLI to your GitHub account:
67
83
68
84
```bash
69
85
gh auth login
70
86
```
71
87
72
-
Create a new repository for your example code:
88
+
3. Create a New Repository
89
+
Create a new public repository for your demo project and clone it locally:
73
90
74
91
```console
75
92
gh repo create arm64-node-demo --public --clone
76
93
cd arm64-node-demo
77
94
```
78
95
79
96
### Create a Dockerfile
80
-
In the root of your project, create a `Dockerfile`that defines how to build and run your application container.
97
+
In the root of your project, create a file named `Dockerfile`to define how your `Node.js` application container will be built and executed.
81
98
82
-
```dockerfile
99
+
```console
83
100
# Dockerfile
84
101
FROM arm64v8/node:20-alpine
85
102
WORKDIR /app
@@ -89,13 +106,18 @@ COPY . .
89
106
EXPOSE 3000
90
107
CMD ["npm", "start"]
91
108
```
92
-
-**Use Arm64 Node.js Image**: The `arm64v8/node` image is specifically designed for Arm64 architecture.
93
-
-**Install Dependencies**: `RUN npm install` installs the project dependencies listed in `package.json`.
94
-
-**Expose Port**: The app will run on port 3000.
95
-
-**Start the App**: The container will execute `npm start` to launch the Node.js server.
109
+
Breakdown of the Dockerfile:
110
+
111
+
- Uses Arm64 Node.js Image: The `arm64v8/node` image is specifically designed for Arm64 architecture.
112
+
- Install Dependencies: `RUN npm install` installs the project dependencies listed in `package.json`.
113
+
- Expose Port: The app will run on port 3000.
114
+
- Start the App: The container will execute `npm start` to launch the Node.js server.
115
+
116
+
Next, you’ll add the application code and a `.circleci/config.yml` file to automate the build and test pipeline using your self-hosted Arm64 runner.
96
117
97
118
### Add a CircleCI Configuration
98
-
Create a `.circleci/config.yml` file to define the CircleCI pipeline for building and testing your Node.js app on Arm64 architecture.
119
+
Create a configuration file that defines your CircleCI pipeline for building, running, and testing your Node.js app on Arm64 architecture.
120
+
In the root of your project, create a folder named `.circleci` and inside it, add a file called `config.yml` with the contents below:
99
121
100
122
```yaml
101
123
version: 2.1
@@ -135,14 +157,17 @@ workflows:
135
157
jobs:
136
158
- arm64-demo
137
159
```
138
-
- **arm64-demo Job**: This job checks if the architecture is Arm64, builds the Docker image, runs it in a container, and tests the app endpoint.
139
-
- **resource_class**: Specify the resource class for the CircleCI runner (e.g., a custom Arm64 runner if using self-hosted).
140
-
- **Test Endpoint**: The job sends a request to the app to verify it’s working.
160
+
161
+
Explanation of the yaml file:
162
+
163
+
- arm64-demo Job: This job checks if the architecture is Arm64, builds the Docker image, runs it in a container, and tests the app endpoint.
164
+
- resource_class: Specify the resource class for the CircleCI runner (e.g., a custom Arm64 runner if using self-hosted).
165
+
- Test Endpoint: The job sends a request to the app to verify it’s working.
141
166
142
167
### Node.js Application
143
-
Here’s the basic code for the Node.js app.
168
+
Create the application files in your repository root directory for the Node.js app.
144
169
145
-
`index.js`:
170
+
Use a file editor of your choice and copy the contents shown below into a file named `index.js`:
146
171
147
172
```javascript
148
173
const express = require('express');
@@ -157,7 +182,8 @@ app.listen(PORT, () => {
157
182
console.log(`Server running on port ${PORT}`);
158
183
});
159
184
```
160
-
package.json
185
+
186
+
Now copy the content below into a file named `package.json`:
161
187
162
188
```json
163
189
{
@@ -173,54 +199,65 @@ package.json
173
199
}
174
200
}
175
201
```
176
-
-**Express Server**: The application uses Express.js to handle HTTP requests and respond with a simple message.
177
-
-**Package Dependencies**: The app requires the `express` package for handling HTTP requests.
202
+
- Express Server: The application uses Express.js to handle HTTP requests and respond with a simple message.
203
+
- Package Dependencies: The app requires the `express` package for handling HTTP requests.
178
204
179
205
### Push Code to GitHub
180
206
181
-
Once all files (`Dockerfile`, `index.js`, `package.json`, `.circleci/config.yml`) are ready, push your project to GitHub so CircleCI can build it automatically.
207
+
Now that all project files (Dockerfile, index.js, package.json, and .circleci/config.yml) are ready, push the code to GitHub.
208
+
This allows CircleCI to automatically detect the repository and trigger your Arm64 build pipeline using the self-hosted runner.
209
+
210
+
Configure Git username and add and commit project files:
-**Add and Commit Changes**: Stage and commit your project files.
190
-
-**Push to GitHub**: Push your code to the GitHub repository so that CircleCI can trigger the build.
218
+
You have pushed your code to the GitHub repository so that CircleCI can trigger the build.
191
219
192
220
### Start CircleCI Runner and Execute Job
193
-
Ensure that your CircleCI runner is enabled and started. This will allow your self-hosted runner to pick up jobs from CircleCI.
221
+
Before triggering your first workflow, ensure that the CircleCI runner service is enabled and running on your SUSE Arm64 VM. This will allow your self-hosted runner to pick up jobs from CircleCI.
194
222
195
-
```console
223
+
```bash
196
224
sudo systemctl enable circleci-runner
197
225
sudo systemctl start circleci-runner
198
226
sudo systemctl status circleci-runner
199
227
```
200
-
-**Enable CircleCI Runner**: Ensure the CircleCI runner is set to start automatically on boot.
201
-
-**Start and Check Status**: Start the CircleCI runner and verify it is running.
228
+
- Enable CircleCI Runner: Ensures the runner service starts automatically on system boot.
229
+
- Start and Check Status: Starts the CircleCI runner and verifies it is running.
230
+
202
231
203
-
After pushing your code to GitHub, open your **CircleCI Dashboard → Projects**, and confirm that your **ARM64 workflow** starts running using your **self-hosted runner**.
232
+
### Verify Job Execution in CircleCI
233
+
234
+
After pushing your code to GitHub, open your CircleCI Dashboard → Projects, and confirm that your Arm64 workflow starts running using your self-hosted runner.
204
235
205
236
If the setup is correct, you’ll see your job running under the resource class you created.
206
237
207
238
### Output
208
-
Once the job starts running, CircleCI will:
239
+
When the CircleCI workflow starts running on your self-hosted Arm64 runner, you’ll see the following stages executed in your CircleCI Dashboard:
209
240
210
-
- Detect the ARM64 architecture.
241
+
1. Detect the ARM64 Architecture
242
+
CircleCI confirms the job is executing on your Arm64 self-hosted runner. This validates that the pipeline is correctly targeting your Google Cloud C4A (Axion) VM.
211
243
212
244

213
245
214
-
- Build the Docker image.
246
+
2. Build the Docker image
247
+
The runner builds the `arm64-node-demo` Docker image using the Dockerfile you defined.
If the app responds successfully, the test confirms that the Node.js web server is running correctly inside the container.
225
260
226
261
If successful, you will see your CircleCI job running and the app deployed in the CircleCI Dashboard.
262
+
263
+
This demonstrates an end-to-end cloud-native CI/CD workflow running natively on SUSE Arm64 with Google Cloud C4A (Axion) as a self-hosted runner on CircleCI.
0 commit comments