Skip to content

Commit c7f4d12

Browse files
committed
Add Dockerfile and required config to build and serve pattern library independently
1 parent 6cb69cc commit c7f4d12

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
./.git*
2+
./build
3+
./docs
4+
./lib
5+
./node_modules
6+
./test

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:19.8.1-alpine as builder
2+
3+
COPY . /frontend-shared
4+
RUN cd /frontend-shared && \
5+
yarn install --frozen-lockfile && \
6+
yarn build-pattern-lib
7+
8+
9+
FROM nginx:1.24.0-alpine
10+
11+
RUN rm -r /usr/share/nginx/html && rm /etc/nginx/conf.d/default.conf
12+
# Copy pattern library static assets, and put them in nginx document root folder
13+
COPY --from=builder /frontend-shared/build /usr/share/nginx/html
14+
COPY ./templates/pattern-library.mustache /usr/share/nginx/html/index.html
15+
COPY conf/nginx.conf /etc/nginx/conf.d/default.conf

conf/nginx.conf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
server {
2+
listen 80 default_server;
3+
charset utf-8;
4+
root /usr/share/nginx/html;
5+
index index.html;
6+
7+
# Handle /_status endpoint with a 200 response once the container is up
8+
location = /_status {
9+
add_header Content-Type text/plain;
10+
return 200 'Success!';
11+
}
12+
13+
# When requesting static paths with an extension, try them, and return a 404 if not found
14+
location ~* .+\..+ {
15+
try_files $uri $uri/ =404;
16+
}
17+
18+
# When requesting a path without extension, try it, and return the index if not found
19+
# This allows for client-side route handling
20+
location / {
21+
try_files $uri $uri/ /index.html$is_args$args;
22+
}
23+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"scripts": {
6767
"build-lib": "babel src/ --out-dir lib/ --extensions '.js,.ts,.tsx' --source-maps --ignore '**/test' --ignore '**/karma.config.js'",
6868
"build": "yarn build-lib && tsc --build src/tsconfig.json",
69+
"build-pattern-lib": "yarn gulp bundle-css && yarn rollup -c rollup.config.js",
6970
"typecheck": "tsc --build src/tsconfig.json",
7071
"lint": "eslint .",
7172
"checkformatting": "prettier --check '**/*.{js,scss,ts,tsx,md}'",

0 commit comments

Comments
 (0)