Skip to content

Commit 6a4d927

Browse files
[feat] added documentation for angular guide for deploy
1 parent 9443d50 commit 6a4d927

File tree

5 files changed

+102
-92
lines changed

5 files changed

+102
-92
lines changed

content/guides/angular/configure-ci-cd.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Learn how to configure CI/CD using GitHub Actions for your Angular
99

1010
## Prerequisites
1111

12-
Complete all the previous sections of this guide, starting with [Containerize Angular application](containerize.md).
12+
Complete all the previous sections of this guide, starting with [Containerize an Angular application](containerize.md).
1313

1414
You must also have:
1515
- A [GitHub](https://github.com/signup) account.
@@ -19,7 +19,7 @@ You must also have:
1919

2020
## Overview
2121

22-
In this section, you'll set up a **CI/CD pipeline** using [GitHub Actions](https://docs.github.com/en/actions) to automatically:
22+
In this section, you'll set up a CI/CD pipeline using [GitHub Actions](https://docs.github.com/en/actions) to automatically:
2323

2424
- Build your Angular application inside a Docker container.
2525
- Run tests in a consistent environment.
@@ -31,7 +31,7 @@ In this section, you'll set up a **CI/CD pipeline** using [GitHub Actions](https
3131

3232
To enable GitHub Actions to build and push Docker images, you’ll securely store your Docker Hub credentials in your new GitHub repository.
3333

34-
### Step 1: Connect your GitHub repository to Docker Hub
34+
### Step 1: Generate Docker Hub Credentials and Set GitHub Secrets"
3535

3636
1. Create a Personal Access Token (PAT) from [Docker Hub](https://hub.docker.com)
3737
1. Go to your **Docker Hub account → Account Settings → Security**.
@@ -61,7 +61,7 @@ To enable GitHub Actions to build and push Docker images, you’ll securely stor
6161
| `DOCKERHUB_TOKEN` | Your Docker Hub access token (created in Step 1) |
6262
| `DOCKERHUB_PROJECT_NAME` | Your Docker Project Name (created in Step 2) |
6363

64-
These secrets let GitHub Actions to authenticate securely with Docker Hub during automated workflows.
64+
These secrets allow GitHub Actions to authenticate securely with Docker Hub during automated workflows.
6565

6666
5. Connect Your Local Project to GitHub
6767

@@ -89,7 +89,7 @@ To enable GitHub Actions to build and push Docker images, you’ll securely stor
8989

9090
This confirms that your local repository is properly linked and ready to push your source code to GitHub.
9191

92-
6. Push Your Source Code to GitHub
92+
6. Push your source code to GitHub
9393

9494
Follow these steps to commit and push your local project to your GitHub repository:
9595

@@ -101,7 +101,7 @@ To enable GitHub Actions to build and push Docker images, you’ll securely stor
101101
This command stages all changes — including new, modified, and deleted files — preparing them for commit.
102102

103103

104-
2. Commit your changes.
104+
2. Commit the staged changes with a descriptive message.
105105

106106
```console
107107
$ git commit -m "Initial commit"
@@ -152,15 +152,15 @@ on:
152152

153153
jobs:
154154
build-test-push:
155-
name: Build, Test and Push Docker Image
155+
name: Build, Test, and Push Docker Image
156156
runs-on: ubuntu-latest
157157

158158
steps:
159159
# 1. Checkout source code
160160
- name: Checkout source code
161161
uses: actions/checkout@v4
162162
with:
163-
fetch-depth: 0 # Fetches full history for better caching/context
163+
fetch-depth: 0
164164

165165
# 2. Set up Docker Buildx
166166
- name: Set up Docker Buildx
@@ -172,15 +172,17 @@ jobs:
172172
with:
173173
path: /tmp/.buildx-cache
174174
key: ${{ runner.os }}-buildx-${{ github.sha }}
175-
restore-keys: ${{ runner.os }}-buildx-
175+
restore-keys: |
176+
${{ runner.os }}-buildx-
176177

177178
# 4. Cache npm dependencies
178179
- name: Cache npm dependencies
179180
uses: actions/cache@v4
180181
with:
181182
path: ~/.npm
182183
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
183-
restore-keys: ${{ runner.os }}-npm-
184+
restore-keys: |
185+
${{ runner.os }}-npm-
184186

185187
# 5. Extract metadata
186188
- name: Extract metadata
@@ -196,31 +198,31 @@ jobs:
196198
context: .
197199
file: Dockerfile.dev
198200
tags: ${{ steps.meta.outputs.REPO_NAME }}-dev:latest
199-
load: true # Load to local Docker daemon for testing
201+
load: true
200202
cache-from: type=local,src=/tmp/.buildx-cache
201203
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
202204

203-
# 7. Run Vitest tests
204-
- name: Run Vitest tests and generate report
205+
# 7. Run Angular tests with Jasmine
206+
- name: Run Angular Jasmine tests inside container
205207
run: |
206208
docker run --rm \
207209
--workdir /app \
208210
--entrypoint "" \
209211
${{ steps.meta.outputs.REPO_NAME }}-dev:latest \
210-
sh -c "npm ci && npx vitest run --reporter=verbose"
212+
sh -c "npm ci && npm run test -- --ci --runInBand"
211213
env:
212214
CI: true
213215
NODE_ENV: test
214216
timeout-minutes: 10
215217

216-
# 8. Login to Docker Hub
218+
# 8. Log in to Docker Hub
217219
- name: Log in to Docker Hub
218220
uses: docker/login-action@v3
219221
with:
220222
username: ${{ secrets.DOCKER_USERNAME }}
221223
password: ${{ secrets.DOCKERHUB_TOKEN }}
222224

223-
# 9. Build and push prod image
225+
# 9. Build and push production image
224226
- name: Build and push production image
225227
uses: docker/build-push-action@v6
226228
with:
@@ -255,14 +257,14 @@ After you've added your workflow file, it's time to trigger and observe the CI/C
255257

256258
1. Commit and push your workflow file
257259

258-
Select "Commit changes…" in the GitHub editor.
260+
- Select "Commit changes…" in the GitHub editor.
259261

260262
- This push will automatically trigger the GitHub Actions pipeline.
261263

262264
2. Monitor the workflow execution
263265

264-
1. Go to the Actions tab in your GitHub repository.
265-
2. Click into the workflow run to follow each step: **build**, **test**, and (if successful) **push**.
266+
- Go to the Actions tab in your GitHub repository.
267+
- Click into the workflow run to follow each step: **build**, **test**, and (if successful) **push**.
266268

267269
3. Verify the Docker image on Docker Hub
268270

@@ -293,7 +295,7 @@ Here's what you accomplished:
293295

294296
- Created a new GitHub repository specifically for your project.
295297
- Generated a secure Docker Hub access token and added it to GitHub as a secret.
296-
- Defined a GitHub Actions workflow to:
298+
- Defined a GitHub Actions workflow that:
297299
- Build your application inside a Docker container.
298300
- Run tests in a consistent, containerized environment.
299301
- Push a production-ready image to Docker Hub if tests pass.

content/guides/angular/containerize.md

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: Containerize a Angular Application
2+
title: Containerize an Angular Application
33
linkTitle: Containerize
44
weight: 10
55
keywords: angular, node, image, initialize, build
6-
description: Learn how to containerize a Angular application with Docker by creating an optimized, production-ready image using best practices for performance, security, and scalability.
6+
description: Learn how to containerize an Angular application with Docker by creating an optimized, production-ready image using best practices for performance, security, and scalability.
77

88
---
99

@@ -22,22 +22,21 @@ Before you begin, make sure the following tools are installed and available on y
2222

2323
## Overview
2424

25-
This guide walks you through the complete process of containerizing a Angular application with Docker. You’ll learn how to create a production-ready Docker image using best practices that improve performance, security, scalability, and deployment efficiency.
25+
This guide walks you through the complete process of containerizing an Angular application with Docker. You’ll learn how to create a production-ready Docker image using best practices that improve performance, security, scalability, and deployment efficiency.
2626

2727
By the end of this guide, you will:
2828

29-
- Containerize a Angular application using Docker.
29+
- Containerize an Angular application using Docker.
3030
- Create and optimize a Dockerfile for production builds.
3131
- Use multi-stage builds to minimize image size.
3232
- Serve the application efficiently with a custom NGINX configuration.
33-
- Follow best practices for building secure and maintainable Docker images.
33+
- Build secure and maintainable Docker images by following best practices.
3434

3535
---
3636

3737
## Get the sample application
3838

39-
Clone the sample application to use with this guide. Open a terminal, change
40-
directory to a directory that you want to work in, and run the following command
39+
Clone the sample application to use with this guide. Open a terminal, navigate to the directory where you want to work, and run the following command
4140
to clone the git repository:
4241

4342
```console
@@ -117,7 +116,7 @@ These updates help ensure your app is easy to deploy, fast to load, and producti
117116
> For full details, see the [Dockerfile reference](/reference/dockerfile/).
118117
119118

120-
### Step 2: Configure the Dockerfile file
119+
### Step 2: Configure the Dockerfile
121120

122121
Copy and replace the contents of your existing `Dockerfile` with the configuration below:
123122

@@ -188,62 +187,64 @@ The `.dockerignore` file tells Docker which files and folders to exclude when bu
188187
Copy and replace the contents of your existing `.dockerignore` with the configuration below:
189188

190189
```dockerignore
191-
# =========================================
192-
# Dependency directories and build output
193-
# =========================================
194-
node_modules/
195-
dist/
196-
out-tsc/
197-
.tmp/
198-
.cache/
199-
.angular/
200-
201-
# =========================================
202-
# Angular CLI, build tools, and test artifacts
203-
# =========================================
204-
coverage/
205-
.vite/
206-
.vitepress/
207-
jest/
208-
cypress/
209-
cypress/screenshots/
210-
cypress/videos/
211-
reports/
212-
playwright-report/
213-
214-
# =========================================
215-
# Environment and log files
216-
# =========================================
190+
# ================================
191+
# Node and build output
192+
# ================================
193+
node_modules
194+
dist
195+
out-tsc
196+
.angular
197+
.cache
198+
.tmp
199+
200+
# ================================
201+
# Testing & Coverage
202+
# ================================
203+
coverage
204+
jest
205+
cypress
206+
cypress/screenshots
207+
cypress/videos
208+
reports
209+
playwright-report
210+
.vite
211+
.vitepress
212+
213+
# ================================
214+
# Environment & log files
215+
# ================================
217216
*.env*
218-
!.env.production
217+
!*.env.production
219218
*.log
220219
*.tsbuildinfo
221220
222-
# =========================================
223-
# IDE and local development files
224-
# =========================================
225-
.vscode/
226-
.idea/
227-
*.swp
221+
# ================================
222+
# IDE & OS-specific files
223+
# ================================
224+
.vscode
225+
.idea
228226
.DS_Store
229227
Thumbs.db
228+
*.swp
230229
231-
# =========================================
232-
# Version control
233-
# =========================================
234-
.git/
230+
# ================================
231+
# Version control & CI files
232+
# ================================
233+
.git
235234
.gitignore
236235
237-
# =========================================
238-
# Docker-specific config files (not needed inside image)
239-
# =========================================
236+
# ================================
237+
# Docker & local orchestration
238+
# ================================
240239
Dockerfile
240+
Dockerfile.*
241241
.dockerignore
242+
docker-compose.yml
242243
docker-compose*.yml
243244
244-
# =========================================
245+
# ================================
245246
# Miscellaneous
246-
# =========================================
247+
# ================================
247248
*.bak
248249
*.old
249250
*.tmp
@@ -338,7 +339,7 @@ With your custom configuration in place, you're now ready to build the Docker im
338339

339340
The updated setup includes:
340341

341-
- Clean, production-ready Nginx configuration tailored specifically for Angular.
342+
- The updated setup includes a clean, production-ready NGINX configuration tailored specifically for Angular.
342343
- Efficient multi-stage Docker build, ensuring a small and secure final image.
343344

344345
After completing the previous steps, your project directory should now contain the following files:
@@ -424,7 +425,7 @@ in a terminal.
424425
$ docker compose up --build -d
425426
```
426427

427-
Open a browser and view the application at [http://localhost:8080](http://localhost:8080). You should see a simple web application preview.
428+
Open a browser and view the application at [http://localhost:8080](http://localhost:8080). You should see your Angular application running in the browser.
428429

429430

430431
To confirm that the container is running, use `docker ps` command:
@@ -458,7 +459,7 @@ $ docker compose down
458459

459460
## Summary
460461

461-
In this guide, you learned how to containerize, build, and run a Angular application using Docker. By following best practices, you created a secure, optimized, and production-ready setup.
462+
In this guide, you learned how to containerize, build, and run an Angular application using Docker. By following best practices, you created a secure, optimized, and production-ready setup.
462463

463464
What you accomplished:
464465
- Initialized your project using `docker init` to scaffold essential Docker configuration files.

0 commit comments

Comments
 (0)