Skip to content

Commit

Permalink
refs #209: Add entrypoint for node modules. (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
ailequal authored Jan 8, 2024
1 parent e636f39 commit 95bc7b9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
38 changes: 14 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,23 @@ LABEL author="Paolo Pustorino <[email protected]>"
ENV INSTALL_DIR=/opt/raneto
ENV PORT=80

# Copy content and configuration
COPY ./custom/server.js $INSTALL_DIR/
COPY ./custom/package.json $INSTALL_DIR/
COPY ./custom/package-lock.json $INSTALL_DIR/
COPY ./custom/config.js $INSTALL_DIR/config.js
COPY ./custom/themes $INSTALL_DIR/themes
COPY ./content $INSTALL_DIR/content
COPY ./assets $INSTALL_DIR/assets
COPY ./custom/patches $INSTALL_DIR/patches

# Install raneto and deps
# Set current working directory
WORKDIR $INSTALL_DIR
RUN npm ci && npm run postinstall

# Move to the theme folder
# to build the public/dist folder.
# Raneto will search for public assets
# here first.
WORKDIR $INSTALL_DIR/themes/spark-playbook
RUN \
npm ci && \
npm run build

WORKDIR $INSTALL_DIR
# Copy content and configuration
COPY ./custom/server.js ./
COPY ./custom/package.json ./
COPY ./custom/package-lock.json ./
COPY ./custom/config.js ./config.js
COPY ./custom/themes ./themes
COPY ./content ./content
COPY ./assets ./assets
COPY ./custom/patches ./patches

# Expose port 80
EXPOSE $PORT

# Let's go
CMD ["npm", "start"]
# Configure the entrypoint script
COPY build/node/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

all: theme-install-dep theme-build up
all: up

up:
docker compose pull
Expand Down
24 changes: 24 additions & 0 deletions build/node/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/ash

set -eo pipefail
BASE=${PWD}

if [ "${1}" = 'npm' ]; then
echo "Installing and building theme..."
cd /opt/raneto/themes/spark-playbook
npm install
npm run build
echo "Finished installing and building theme."

echo "Installing raneto's npm libraries..."
cd /opt/raneto
npm install
npm run postinstall
echo "Finished installing raneto's npm libraries."

echo "...done\n"
fi

cd ${BASE}
echo "Running command: ${@}"
exec "$@"
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
build: .
environment:
- VIRTUAL_HOST=playbook.sparkfabrik.loc
command: npm run start
volumes:
- ./assets:/opt/raneto/assets
- ./content:/opt/raneto/content
Expand Down

0 comments on commit 95bc7b9

Please sign in to comment.