-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-voice
80 lines (53 loc) · 3.11 KB
/
Dockerfile-voice
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
64
65
66
67
68
69
70
71
72
73
74
75
76
FROM node:16.13.1-alpine
# Use "LABEL" instead of "MAINTAINER"
LABEL @author=vuong@hoccoban.com
#SCOPE ALERT: ARG before FROM is outside of the build : ARG should be put after FROM https://stackoverflow.com/questions/43654656/dockerfile-if-else-condition-with-external-arguments/43656644#43656644
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
# data for developmentorproduction will be provided in docker-compose run defined inside zboot.sh
# Default value = "d" : development
#ARG developmentorproduction=d;
#RUN echo $developmentorproduction
#https://stackoverflow.com/questions/38323880/error-eacces-permission-denied
#RUN npm init
# UPGRADE: The default use "root" --> required to install npm globally.
# RUN npm install -g npm@latest
ARG kiwi_arg=123;
#seem does not work
RUN echo "Environment variable: " $kiwi_arg
RUN npm install -g npm@8.3.1 &\
npm install pm2 -g
# Creat a folder and set the chown
RUN mkdir -p /srv/vietspeak/kiwi && chown -R node:node /srv/vietspeak/kiwi
# Switching to user name "node" from "root" user.
USER node
# srv folder is seen the best place to store the code. People might use /var/www/html or urs/src. @Ref: https://jdlm.info/articles/2019/09/06/lessons-building-node-app-docker.html
WORKDIR /srv/vietspeak/kiwi
# * means everthing
# It does not work if we the use is set to "node" [the user generated by nodejs]
# COPY package*.json ./
# We need to set chown for the use "node", so copy and chown
COPY --chown=node:node package.json package-lock.json ./
# DEVELOPMENT: Make use nestjs cli is NOT missed. You should be aware of nestjs cli as it is required. Note that nestjs cli is used for dev only. Check out the following link to see some good recommendation--> https://stackoverflow.com/questions/62463702/npm-script-fails-with-sh-1-command-not-found-in-docker-container
# DEVELOPMENT: Running with -g on global scope, which is not necessary. -g flag
# RUN npm install -g @nestjs/cli && npm install
# DEVELOPMENT Running with -save for current project: https://stackoverflow.com/questions/25092617/npm-install-bower-using-g-vs-save-dev
# npm cache verify: check cache if any
# npm clean cache --force: remove cache if needed
# Reduce the time to run npm install. See: https://github.com/npm/npm/issues/7862#issuecomment-220798263
RUN npm config set registry=https://registry.npmjs.com/ &&\
npm config set strict-ssl false &&\
npm cache verify &&\
npm install
#npm install formidable@v3
# PRODUCTION: Uncomment the TWO following lines if you want to run the app on production
# RUN npm install -g @nestjs/cli && npm install --only=production
# RUN npm run build
# Copy everything from current folder one host to container.
# https://stackoverflow.com/questions/68855526/missing-dependencies-after-using-docker-compose COPY EVEYTHING IS NOT NEEDED?
COPY . .
# HOST - DEBUG ONLY: Check the directory to see the output. The following command is used for observation only.
RUN ls -l
CMD node voice.js
#CMD pm2 start voice.js
#https://stackoverflow.com/questions/51191378/what-is-the-point-of-using-pm2-and-docker-together
#CMD ["pm2-runtime", "voice.js"]