-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
31 lines (23 loc) · 1.19 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
# The build process is split into two steps
# 1. We use a python3 docker image to install jinja-cli to render the index.html
# 2. In an nginx docker image we then copy in all the artifacts for serving. This is what ultimately serves traffic
FROM python:3 AS renderer
RUN pip install --no-cache-dir jinja-cli
WORKDIR /simulator
# Make a copy of the repo so that we can retrieve the most recent git hash
# We then pass this git hash into jinja so we can render the html
COPY . /simulator
RUN CACHE_KEY=$(date +%Y%m%d%H%M) && \
echo "{\"cache_key\": \"$CACHE_KEY\", \"prod\": true}" > context.json && \
jinja -d context.json templates/index.html > rendered_index.html
# Template file has already been rendered, so just copy it over
# and host everything using basic nginx
FROM nginx:latest AS serving
MAINTAINER Charles Hong <charleshong@pioneers.berkeley.edu>
# Create the expected file structure in the image
COPY --from=renderer /simulator/rendered_index.html /usr/share/nginx/html/index.html
COPY static /usr/share/nginx/html/static
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
# docker build -t webserver .
# docker run -it --rm -d -p 8080:80 --name web webserver
# Navigate to localhost:8080