ARG NGINX_VERSION=${NGINX_VERSION}

FROM --platform=$TARGETPLATFORM docker.jfrog.io/ubuntu:18.04 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 --platform=$TARGETPLATFORM docker.jfrog.io/nginx:${NGINX_VERSION}

COPY Dockerfile /docker/art-nginx/

RUN apk --no-cache add shadow && \
    apk --no-cache add libcap && \
    apk --no-cache add dcron && \
    apk --no-cache add bash && \
    apk --no-cache add logrotate && \
    apk --no-cache add --update busybox-suid && \
    apk --no-cache upgrade curl libcurl apk-tools && \
    apk del nginx-module-xslt nginx-module-image-filter

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