Skip to content

Commit 5c01b06

Browse files
committed
dev: Implement test environment to test the built website cleanly
This change allow one to test the website in an clean environment by running: ``` docker compose --profile=test up -d ``` after: ``` grunt dist ``` and browse <http://localhost:8080> using one's web browser. Signed-off-by: 林博仁(Buo-ren Lin) <[email protected]>
1 parent 32280b0 commit 5c01b06

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

dev-utils/nginx-default.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Default website virtual host configuration of the NGINX container
2+
server {
3+
listen 80;
4+
server_name localhost;
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
}
9+
error_page 500 502 503 504 /50x.html;
10+
location = /50x.html {
11+
root /usr/share/nginx/html;
12+
}
13+
charset utf-8;
14+
}

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ services:
3636
command: sleep infinity
3737
profiles:
3838
- dev
39+
40+
# Environment for testing the project
41+
test-environment:
42+
container_name: www-moztw-org-test
43+
hostname: www-moztw-org-test
44+
image: nginx:1.27-alpine
45+
volumes:
46+
- type: bind
47+
source: ./_site
48+
target: /usr/share/nginx/html
49+
read_only: true
50+
- type: bind
51+
source: ./dev-utils/nginx-default.conf
52+
target: /etc/nginx/conf.d/default.conf
53+
read_only: true
54+
ports:
55+
# For serving the website
56+
- 8080:80
57+
profiles:
58+
- test

0 commit comments

Comments
 (0)