-
Notifications
You must be signed in to change notification settings - Fork 0
Dockerfile
thehappycheese edited this page Apr 30, 2021
·
6 revisions
FROM rust:1.51-slim as builder
WORKDIR /home/
RUN apt-get update
RUN apt-get install -y libssl-dev pkg-config
# libssl-dev is a dependency
# pkg-config is used by the toolchain to locate libssl-dev
# Note: the --branch specified below is actually a tag, referring to a specific commit.
RUN apt-get install -y git
RUN git --work-tree=./repo \
clone https://github.com/thehappycheese/nicklinref_rust.git \
--branch docker_build \
--depth=1 \
delme/
RUN rm -rf delme
WORKDIR /home/repo/
RUN cargo install --path . --root /home/out/
# resulting binary will be at /home/out/bin/nicklinref
# TODO: we will need to check what distro is available in Azure's registry I guess?
FROM debian:buster-slim
# Sadly, rust will dynamically link to libc and libssl
# Statically linking them is a big mission.
# Therefore we need them installed here
# Further, openssl will trust nothing by default,
# the ca-certificates tool is used to fetch and install
# root certificates from the trusted providors.
# This is needed so the tool can fetch data from https://mrgis.mainroads.wa.gov.au/
RUN apt-get update
RUN apt-get install -y libssl-dev ca-certificates
RUN update-ca-certificates
# ================================================
# Lets make a dodgy self-signed SSL certificate!
# This will cause a nasty warning screen when testing in the browser, as it should.
# TODO: substitute this bit by obtaining a properly issued certificates and getting them in here somehow
RUN apt-get install -y openssl
WORKDIR /home/
RUN mkdir certs
WORKDIR /home/certs/
RUN openssl req \
-new \
-newkey rsa:4096 \
-days 365 \
-nodes -x509 \
-subj "/C=AU/ST=WA/L=Perth/O=thehappycheese/CN=localhost" \
-keyout decrypted_private.key \
-out public.crt
# ================================================
EXPOSE 8080
ENV NLR_PORT=8080
ENV NLR_ADDR=0.0.0.0
ENV NLR_DATA_FILE=/home/data/data.json.lz4
ENV NLR_DATA_SOURCE_URL=https://mrgis.mainroads.wa.gov.au/arcgis/rest/services/OpenData/RoadAssets_DataPortal/MapServer/17/query?where=1%3D1&outFields=ROAD,START_SLK,END_SLK,CWY&outSR=4326&f=json
ENV NLR_STATIC_HTTP=/home/__static_http
ENV NLR_CERT_PATH=/home/certs/public.crt
ENV NLR_PRIVATE_KEY_PATH=./certs/decrypted_private.key
COPY --from=builder /home/out/bin/nicklinref /home/nicklinref
COPY --from=builder /home/repo/__static_http /home/__static_http
# TODO: there is an optional file call secrets.json that needs to be coppied
# into __static_http at this stage because it is not part of the repo.
WORKDIR /home/
VOLUME /home/data/
CMD ["./nicklinref"]