Skip to content

Commit bfc8681

Browse files
committed
move npm ci to startup script
1 parent 84e1cec commit bfc8681

File tree

6 files changed

+39
-21
lines changed

6 files changed

+39
-21
lines changed

Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ In order to have the code up and running on your machine, build the Docker conta
7171
docker-compose up
7272
```
7373

74+
If there is `node_modules` directory, it will perform a clean install from
75+
`package-lock.json`.
76+
7477
### Step 5: Access the Application
7578

7679
Once the container is running, you can access the Creative Commons Chooser application by navigating to the following URL in your web browser:
@@ -87,13 +90,13 @@ http://localhost:8080
8790
### Commands
8891
Run the following commands in order to have the code up and running on your machine:
8992

93+
Clean install dependencies from package-lock.json:
9094
``` bash
91-
# install dependencies
92-
npm install
95+
npm ci
9396
```
9497

98+
Build and serve assets with hot-reload
9599
```bash
96-
# Build and serve assets with hot-reload
97100
npm run serve
98101
```
99102

dev/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://docs.docker.com/reference/dockerfile/
2+
3+
# https://hub.docker.com/_/node/
4+
FROM node:14
5+
6+
WORKDIR /app
7+
8+
EXPOSE 8080
9+
10+
COPY startupservice.sh /usr/local/sbin/startupservice.sh
11+
RUN chmod +x /usr/local/sbin/startupservice.sh
12+
CMD /usr/local/sbin/startupservice.sh

dev/startupservice.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o nounset
4+
5+
cd /app
6+
7+
if [[ ! -d node_modules ]]
8+
then
9+
echo 'Clean installing packages from package-lock.json'
10+
npm ci
11+
echo
12+
fi
13+
14+
npm run serve

docker-compose.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ version: '2.4'
55
services:
66

77
web:
8-
# Build configuration in Dockerfile
9-
build: .
8+
# Build configuration in dev/Dockerfile
9+
build: dev
1010
ports:
1111
- '8080:8080'
1212
restart: on-failure
1313
stdin_open: true
1414
tty: true
1515
volumes:
16-
# Mount the current directory from the host to /app in the container
1716
- '.:/app'
18-
# Mount the /app/node_modules directory from the host
19-
- '/app/node_modules'

publish.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -o errexit
43
set -o errtrace
54
set -o nounset
@@ -12,10 +11,13 @@ trap '_es=${?};
1211

1312
echo "Deleting contents of dist folder"
1413
rm -rf dist/*
14+
echo
1515

1616
echo "Starting build"
17-
npm run build-component
17+
docker compose exec web npm run build-component
1818
echo "Finished build"
19+
echo
1920

2021
echo "Starting publish"
21-
npm publish --access public
22+
docker compose exec web npm publish --access public
23+
echo

0 commit comments

Comments
 (0)