FROM docker.jfrog.io/ubuntu:18.10 as builder

MAINTAINER devops@jfrog.com

# Install openssl and create example TLS key and certificate
RUN apt-get update && \
    apt-get install -y openssl && \
    mkdir -p /etc/tls/private && mkdir -p /etc/tls/certs && \
    openssl genrsa -out /etc/tls/private/example.key 2048 && \
    openssl req -new -key /etc/tls/private/example.key -out /tmp/example.csr -subj "/C=US/ST=California/L=SantaClara/O=IT/CN=localhost" && \
    openssl x509 -req -days 365 -in /tmp/example.csr -signkey /etc/tls/private/example.key -out /etc/tls/certs/example.crt

FROM docker.jfrog.io/ubuntu:18.10

COPY --from=builder /etc/tls/private/example.key /etc/tls/private/example.key
COPY --from=builder /etc/tls/certs/example.crt   /etc/tls/certs/example.crt

COPY Dockerfile /docker/art-nginx/

ENV NGINX_VERSION 1.15.5-1

# Install nginx and libcap2-bin (so can run setcap)
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y libcap2-bin nginx curl && \
    rm -rf /var/lib/apt/lists/*
