-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
58 lines (45 loc) · 1.55 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
FROM ubuntu:20.04 AS base
ENV TZ=Europe/Lisbon
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update
RUN apt-get install -y nlohmann-json3-dev
RUN apt-get install -y libwebsocketpp-dev libasio-dev
## Redirect to swagger
WORKDIR /var/www/html
RUN ln -s /swagger/node_modules/swagger-ui-dist swagger-ui
FROM base AS base-with-makers
RUN apt-get install -y cmake
RUN apt-get install -y npm
RUN apt-get install -y python3
FROM base-with-makers as dev
COPY run.dev.sh /
RUN chmod +x /run.dev.sh
CMD /run.dev.sh
FROM base-with-makers AS prod-build
## Install app
COPY app /app
RUN mkdir -p /tmp/app/build/
WORKDIR /tmp/app/build/
RUN cmake /app -DCMAKE_BUILD_TYPE=Release
RUN cmake --build . --target dynaminator -j8
RUN cmake --install .
RUN rm -rf /tmp/app/
## Install swagger and generate docs
COPY web/swagger /swagger
WORKDIR /app/
RUN chmod 755 /swagger/docs-swagger.py
RUN /swagger/docs-swagger.py > /var/www/html/swagger.yaml
RUN chmod 755 /var/www/html/swagger.yaml
WORKDIR /swagger/
RUN npm install
COPY web/swagger/swagger-initializer.js /swagger/node_modules/swagger-ui-dist/swagger-initializer.js
FROM base as prod
COPY --from=prod-build /var/www/html/swagger.yaml /var/www/html/swagger.yaml
COPY --from=prod-build /swagger/node_modules/swagger-ui-dist /swagger/node_modules/swagger-ui-dist
COPY --from=prod-build /usr/local/bin/dynaminator /usr/local/bin/dynaminator
## Cleanup as much as possible
RUN apt-get clean
RUN rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
COPY run.sh /
RUN chmod +x /run.sh
CMD /run.sh