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

MAINTAINER devops@jfrog.com

ENV NGINX_VERSION 1.19.2-1

# 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/nginx:1.19.2-alpine

COPY Dockerfile /docker/art-nginx/

RUN apk --no-cache add shadow && \
    apk --no-cache add libcap && \
    apk --no-cache add bash

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