This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use docker multi-stage build (#193)
thanks to @dmlemos
- Loading branch information
Showing
2 changed files
with
22 additions
and
23 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,26 +1,30 @@ | ||
FROM node:8-alpine | ||
|
||
RUN apk add --no-cache git | ||
FROM node:8-alpine AS builder | ||
|
||
# Set environment variables | ||
ENV USER_DIR=/usr/src/app | ||
ENV STATUSFY_VERSION 0.3.1 | ||
ENV NODE_ENV production | ||
ENV STATUSFY_VERSION=0.3.1 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN \ | ||
set -x \ | ||
&& yarn install \ | ||
&& yarn add "statusfy@$STATUSFY_VERSION" \ | ||
&& npx statusfy build | ||
|
||
|
||
FROM node:8-alpine | ||
|
||
ENV NODE_ENV production | ||
ENV HOST 0.0.0.0 | ||
ENV PORT 3000 | ||
ENV WORKDIR /usr/src/app | ||
|
||
RUN mkdir -p $USER_DIR | ||
RUN chown node:node "$USER_DIR" | ||
WORKDIR $USER_DIR | ||
|
||
# RUN yarn cache clean | ||
# RUN yarn global add "statusfy@$STATUSFY_VERSION" | ||
COPY --from=builder --chown=node:node /usr/src/app/ $WORKDIR | ||
|
||
COPY ./scripts/docker-start.sh /start.sh | ||
RUN chmod +x /start.sh | ||
|
||
VOLUME $USER_DIR | ||
WORKDIR $WORKDIR | ||
VOLUME $WORKDIR | ||
EXPOSE $PORT | ||
|
||
CMD ["sh", "/start.sh"] | ||
CMD ["/start.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
set -e | ||
|
||
cd $USER_DIR | ||
|
||
yarn cache clean | ||
NODE_ENV=development yarn install | ||
yarn add "statusfy@$STATUSFY_VERSION" | ||
|
||
npx statusfy build | ||
echo "Starting server..." | ||
npx statusfy start |