This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfileManual
63 lines (49 loc) · 1.92 KB
/
DockerfileManual
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM alpine:latest
# replace shell with bash so we can source files
# RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ENV NVM_VERSION=0.33.6 NODE_VERSION=8.9.0 ENV=/root/.ashrc
RUN apk add --update --no-cache curl bash autoconf \
ca-certificates openssl coreutils && \
apk add --update --no-cache --virtual build-dependencies ncurses python2 \
make gcc g++ libgcc linux-headers && \
cd /root && \
curl -o- https://raw.githubusercontent.com/creationix/nvm/v$NVM_VERSION/install.sh | bash && \
echo "#NVM Setup" >> $ENV && \
echo 'export NVM_DIR="$HOME/.nvm"' >> $ENV && \
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> $ENV && \
source $ENV && \
nvm install -s v$NODE_VERSION --fully-static && \
rm -rf /root/.nvm/.cache/src/node-v$NODE_VERSION && \
apk del build-dependencies && \
rm -rf /tmp/* /var/cache/apk/*
# install tool for npm lib compile in C
RUN apk add --update --no-cache autoconf libtool automake alpine-sdk
# add node and npm to path so the commands are available
ENV NVM_DIR /root/.nvm
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# add node_modules binaries to PATH (nodejs look for node_modules in parent directories)
ENV PATH NODE_PATH:$PATH
# confirm installation
RUN node -v
RUN npm -v
#install pm2 to rpduction (monitoring) (need specific command in compose)
RUN npm install pm2 -g
#install nodemon to dev (support hot realoading) (need specific command in compose)
RUN npm install nodemon -g
# define app folder
RUN mkdir -p /root/app
WORKDIR /root/app
# install app dependencies
ADD ./package.json .
RUN npm cache clean --force && npm install
# add src & build configuraiton
ADD ./.babelrc .
ADD ./webpack.config.js .
ADD src ./src
# build src in dist
RUN npm run build
EXPOSE 8080
CMD [ "node", "./dist/server/app.js"]