-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Docker image to run server via pm2 instead of serving static f…
…iles only
- Loading branch information
1 parent
670043d
commit 40fbd41
Showing
6 changed files
with
61 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
FROM node:20-alpine | ||
WORKDIR /usr/src/app | ||
|
||
## We need bash and git | ||
RUN apk add --no-cache bash | ||
RUN apk add --no-cache git | ||
|
||
## Show version numbers for Node and npm | ||
RUN node -v | ||
RUN npm -v | ||
# Copy and install dependencies | ||
COPY package*.json ./ | ||
RUN npm ci | ||
|
||
# Bundle app source | ||
COPY . . | ||
|
||
# Use pm2 to run app | ||
RUN npm i -g pm2 | ||
|
||
ENV NODE_ENV=production | ||
|
||
## Make Docker-related scripts available in root folder | ||
COPY .docker/*.sh . | ||
|
||
## Use http-server for serving the site | ||
RUN npm i -g http-server | ||
# Build Vue frontend for default configuration | ||
RUN bash ./build.sh | ||
|
||
CMD ["bash", "entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Clone site if not yet done | ||
if [ ! -e .git ]; then | ||
git init -b main | ||
git remote add origin https://github.com/gbv/coli-rich-web.git | ||
git fetch | ||
git checkout -t origin/main | ||
fi | ||
|
||
# Pull changes | ||
git pull | ||
# We need to rebuild the front-end if environment differs from default | ||
|
||
env () { | ||
echo "$(git rev-parse HEAD) ### $BASE" | ||
} | ||
env_file=dist/.build-env | ||
base_file=dist/.base | ||
base="$BASE /// $VITE_LOGIN_SERVER" | ||
|
||
if [ -e $env_file ] && [ "$(env)" == "$(cat $env_file)" ]; then | ||
echo "Site rebuild skipped because there was no update." | ||
if [[ -e $base_file && "$base" == "$(cat $base_file)" ]]; then | ||
echo "Front-end rebuild skipped." | ||
else | ||
# Might need to update dependencies after each pull | ||
npm ci | ||
echo "Rebuilding front-end because configuration changed..." | ||
# Build the site | ||
npm run build | ||
# Remember the current commit | ||
env > $env_file | ||
# Remember the current environment | ||
echo "$base" > $base_file | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters