Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
feat: use docker multi-stage build (#193)
Browse files Browse the repository at this point in the history
thanks to @dmlemos
  • Loading branch information
juliomrqz committed May 6, 2019
1 parent 2eb3a70 commit 2b12153
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
34 changes: 19 additions & 15 deletions Dockerfile
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"]
11 changes: 3 additions & 8 deletions scripts/docker-start.sh
100644 → 100755
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

0 comments on commit 2b12153

Please sign in to comment.