-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
73 lines (60 loc) · 1.71 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
# === build react ===
FROM node:14-alpine AS builder
LABEL stage=builder
ENV NODE_ENV production
WORKDIR /app
COPY ./web/package.json .
COPY ./web/package-lock.json .
# update npm
RUN npm i -g npm@8
RUN npm ci --include=dev
# copy app files
COPY ./web .
# build the app
RUN npm run build
FROM ubuntu:20.04
SHELL ["/bin/bash", "-c"]
# === install ===
# install dependency
RUN apt update
RUN apt install -y wget gnupg libcurl4 openssl liblzma5
# install mongodb
WORKDIR /usr/mongo
RUN mkdir -p /usr/mongo
RUN wget -nv https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.15.tgz
RUN tar -zxvf mongodb-linux-x86_64-ubuntu2004-4.4.15.tgz
RUN cp /usr/mongo/mongodb-linux-x86_64-ubuntu2004-4.4.15/bin/* /usr/local/bin/
# install python
RUN apt install -y python3 python3-pip
RUN python3 --version
# install nginx
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y nginx
# === prepare ===
WORKDIR /app
COPY . .
# === build flask ===
WORKDIR /app/server
# install
RUN python3 -m pip install --upgrade pip
RUN pip3 install --no-cache-dir -r requirements.txt
# === config ===
# setup nginx
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
RUN rm -rf /usr/share/nginx/html
COPY --from=builder /app/build /usr/share/nginx/html
EXPOSE 80
# === setup ===
WORKDIR /app/setup
# prepare required dir
RUN mkdir -p /data/db
RUN mkdir -p /app/logs
RUN chmod +x ./init_mongodb.sh
RUN chmod +x ./entrypoint.sh
# init mongodb
ARG MONGODB_USER
ARG MONGODB_PASSWORD
RUN sed -i -e 's/USER/'$MONGODB_USER'/g' ./init_mongodb_create_user.js
RUN sed -i -e 's/PWD/'$MONGODB_PASSWORD'/g' ./init_mongodb_create_user.js
RUN mongod --fork --logpath /app/logs/mongodb.log && ./init_mongodb.sh
# entry point shell
ENTRYPOINT ["/app/setup/entrypoint.sh"]