Skip to content

Commit

Permalink
Fix issue with Docker image front-end
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jan 25, 2024
1 parent 288ffca commit 4887a5b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM node:20-alpine

WORKDIR /usr/src/app

RUN apk add --no-cache bash
RUN apk add --no-cache gawk

# Copy and install dependencies
Expand All @@ -18,4 +19,7 @@ RUN npm run build
RUN npm i -g pm2
RUN cp ecosystem.example.json ecosystem.config.json

CMD pm2-runtime ecosystem.config.json
## Make Docker-related scripts available in root folder
COPY docker/*.sh .

CMD ["bash", "entrypoint.sh"]
15 changes: 15 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# We need to rebuild the front-end if $BASE changed

base_file=dist/.base

if [[ -e $base_file && "$BASE" == "$(cat $base_file)" ]] || [[ ! -e $base_file && "$BASE" == "" ]]; then
echo "Front-end rebuild skipped."
else
echo "Rebuilding front-end because \$BASE changed to $BASE..."
# Build the site
npm run build
# Remember the current $BASE
echo "$BASE" > $base_file
fi
6 changes: 6 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Build site in background
bash build.sh &

pm2-runtime ecosystem.config.json

0 comments on commit 4887a5b

Please sign in to comment.