Skip to content

Commit

Permalink
move npm ci to startup script
Browse files Browse the repository at this point in the history
  • Loading branch information
TimidRobot committed Apr 11, 2024
1 parent 84e1cec commit bfc8681
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 21 deletions.
10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ In order to have the code up and running on your machine, build the Docker conta
docker-compose up
```

If there is `node_modules` directory, it will perform a clean install from
`package-lock.json`.

### Step 5: Access the Application

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

Clean install dependencies from package-lock.json:
``` bash
# install dependencies
npm install
npm ci
```

Build and serve assets with hot-reload
```bash
# Build and serve assets with hot-reload
npm run serve
```

Expand Down
12 changes: 12 additions & 0 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.docker.com/reference/dockerfile/

# https://hub.docker.com/_/node/
FROM node:14

WORKDIR /app

EXPOSE 8080

COPY startupservice.sh /usr/local/sbin/startupservice.sh
RUN chmod +x /usr/local/sbin/startupservice.sh
CMD /usr/local/sbin/startupservice.sh
14 changes: 14 additions & 0 deletions dev/startupservice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -o errexit
set -o nounset

cd /app

if [[ ! -d node_modules ]]
then
echo 'Clean installing packages from package-lock.json'
npm ci
echo
fi

npm run serve
7 changes: 2 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ version: '2.4'
services:

web:
# Build configuration in Dockerfile
build: .
# Build configuration in dev/Dockerfile
build: dev
ports:
- '8080:8080'
restart: on-failure
stdin_open: true
tty: true
volumes:
# Mount the current directory from the host to /app in the container
- '.:/app'
# Mount the /app/node_modules directory from the host
- '/app/node_modules'
8 changes: 5 additions & 3 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -o errexit
set -o errtrace
set -o nounset
Expand All @@ -12,10 +11,13 @@ trap '_es=${?};

echo "Deleting contents of dist folder"
rm -rf dist/*
echo

echo "Starting build"
npm run build-component
docker compose exec web npm run build-component
echo "Finished build"
echo

echo "Starting publish"
npm publish --access public
docker compose exec web npm publish --access public
echo

0 comments on commit bfc8681

Please sign in to comment.