-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
94 lines (78 loc) · 2.25 KB
/
Dockerfile
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
################################################
# BUILD #
################################################
FROM node:12-alpine AS Build
# Create app directory
WORKDIR /frontend
# Install app dependencies ( everything )
# A wildcard is used to ensure both package.json AND package-lock.json are copied where available (npm@5+)
COPY package*.json ./
RUN npm ci --no-optional
# copy every file
COPY . .
# Build everything
RUN npm run build
################################################
# PRODUCTION #
################################################
FROM node:12-alpine AS Package
# Create app directory
WORKDIR /frontend
# Needed tool to export ENV variables into a json file
RUN apk --no-cache add jq
# Copy generated files from build
COPY --from=Build /frontend ./
COPY package*.json ./
# TODO Only Install production dependancies (later)
#RUN npm ci --only=production
RUN npm ci --no-optional
# Removes unnecessary files/folders in node modules
# Files
RUN find "$(pwd)/node_modules" -type f \( \
-name "*.ts" -o \
-name "*.md" -o \
-name "*.swp" -o \
-name "*.tgz" -o \
-name ".npm*" -o \
-name "LICENSE" -o \
-name "AUTHORS" -o \
-name "CONTRIBUTORS" -o \
-name "CHANGES" -o \
-name ".DS_Store" -o \
-name ".babelrc" -o \
-name "jest.config.js" -o \
-name "tslint.json" -o \
-name "eslint" -o \
-name ".eslintrc.js" -o \
-name ".eslintrc.json" -o \
-name ".eslintrc.yml" -o \
-name ".prettierrc*" -o \
-name ".travis.yml" -o \
-name ".gitlab-ci.yml" -o \
-name "appveyor.yml" -o \
-name ".coveralls.yml" \
\) -exec rm -f {} \;
# Folders
RUN find "$(pwd)/node_modules" -type d \( \
-name "docs" -o \
-name "doc" -o \
-name "tests" -o \
-name "test" -o \
-name "__tests__" -o \
-name "example" -o \
-name "examples" -o \
-name ".nyc_output" -o \
-name ".idea" -o \
-name ".vscode" -o \
-name "coverage" -o \
-name ".github" -o \
-name ".circleci" \
\) -prune -exec rm -rf {} +;
# Default port
EXPOSE 3000
# set app serving to permissive / assigned
ENV NUXT_HOST=0.0.0.0
# set app port
ENV NUXT_PORT=3000
# start the app
CMD jq -n env > config/production.json && npm run prod