Skip to content

Commit

Permalink
add error handling to startup logic (sigp#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
antondlr authored and magick93 committed Feb 13, 2025
1 parent fcfff0c commit d16588d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
33 changes: 10 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,27 @@ ARG node_image=node:${node_version}

FROM $node_image AS builder

ENV NEXT_TELEMETRY_DISABLED=1 \
NODE_ENV=development
WORKDIR /app
COPY . /app/

ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=development

WORKDIR /app
RUN yarn --network-timeout 300000
RUN yarn --network-timeout 300000; \
NODE_ENV=production yarn build
WORKDIR /app/backend
RUN yarn --network-timeout 300000

ENV NODE_ENV=production

RUN yarn build
WORKDIR /app
RUN yarn build

FROM node:${node_version}-alpine AS production
RUN yarn --network-timeout 300000; \
NODE_ENV=production yarn build

WORKDIR /app

ENV NODE_ENV=production
RUN npm install --global pm2
RUN apk add -U nginx openssl
FROM alpine AS intermediate

COPY ./.env.example /app/
COPY ./docker-assets /app/docker-assets/
RUN rm /etc/nginx/http.d/default.conf; \
ln -s /app/docker-assets/siren-http.conf /etc/nginx/http.d/siren-http.conf

COPY --from=builder /app/backend/package.json /app/backend/package.json
COPY --from=builder /app/backend/node_modules /app/backend/node_modules
COPY --from=builder /app/backend/dist /app/backend/dist

COPY --from=builder /app/siren.js /app/siren.js
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/siren.js /app/package.json /app/
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/public /app/public
COPY --from=builder /app/.next /app/.next
Expand Down
6 changes: 3 additions & 3 deletions docker-assets/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ if [ $SSL_ENABLED = true ]; then
openssl req -x509 -newkey rsa:4096 -keyout /certs/key.pem -out /certs/cert.pem -days 365 -passout pass:'sigmaprime' -subj "/C=AU/CN=siren/[email protected]"
echo 'sigmaprime' > /certs/key.pass
fi
## nginx ssl stuff
ln -s /app/docker-assets/siren-https.conf /etc/nginx/http.d/siren-https.conf
ln -s /app/docker-assets/siren-https.conf /etc/nginx/http.d/siren-https.conf
fi

# test config, start nginx
Expand All @@ -52,5 +51,6 @@ nginx -t && nginx &
cd /app/backend
PM2_HOME='~/.pm2-backend' pm2-runtime yarn --interpreter sh -- start:prod &

# start frontend
cd /app
PM2_HOME='~/.pm2-frontend' pm2-runtime yarn --interpreter sh -- start
PM2_HOME='~/.pm2-frontend' pm2-runtime yarn --interpreter sh -- start

0 comments on commit d16588d

Please sign in to comment.