Skip to content

Commit

Permalink
add an init process, refactor the entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
paolomainardi committed Jan 15, 2024
1 parent aff5666 commit 0e8a461
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM node:18-alpine as dev
LABEL author="Paolo Pustorino <[email protected]>"

RUN apk add --no-cache tini

# Variables
ENV INSTALL_DIR=/opt/raneto
ENV PORT=80
Expand All @@ -23,9 +25,20 @@ EXPOSE $PORT
# Configure the entrypoint script
COPY build/node/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["npm run start"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["npm", "run", "start"]
ENTRYPOINT ["tini", "--", "/entrypoint.sh"]

FROM dev as prod

WORKDIR /opt/raneto
RUN cd custom && npm install
# Production build, must be all moved in a shared script.
RUN cd themes/spark-playbook && \
npm install && \
npm run build && \
cd /opt/raneto && \
npm install && \
npm run postinstall

# This should be moved before instaoll, but for some reasons it breaks the build.
# We just use it now for the entrypoint.
ENV NODE_ENV=production
4 changes: 2 additions & 2 deletions build/node/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -eo pipefail
BASE=${PWD}

if [ "${1}" = 'npm' ]; then
echo "Installing and building theme..."
if [ "${1}" = 'npm' ] && [ "$NODE_ENV" != 'production' ]; then
echo "Installing and building theme..."
cd /opt/raneto/themes/spark-playbook
npm install
npm run build
Expand Down

0 comments on commit 0e8a461

Please sign in to comment.