|
| 1 | +############# |
| 2 | +# Go Builder |
| 3 | +############# |
| 4 | + |
| 5 | +FROM --platform=${TARGETPLATFORM:-linux/amd64} golang as go |
| 6 | + |
| 7 | +ENV MKCERT_VERSION=1.4.2 |
| 8 | +RUN mkdir /workspace |
| 9 | +WORKDIR /workspace |
| 10 | +RUN go get github.com/amacneil/dbmate |
| 11 | +RUN wget -O mkcert.tgz "https://github.com/FiloSottile/mkcert/archive/v${MKCERT_VERSION}.tar.gz" |
| 12 | +RUN tar -xzf mkcert.tgz |
| 13 | +WORKDIR "/workspace/mkcert-${MKCERT_VERSION}" |
| 14 | +RUN go build -ldflags "-X main.Version=v${MKCERT_VERSION}" -o /bin/mkcert |
| 15 | + |
| 16 | +############# |
| 17 | +# Nginx Builder |
| 18 | +############# |
| 19 | + |
| 20 | +FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:stable-slim as builder |
| 21 | + |
| 22 | +ARG OPENRESTY_VERSION |
| 23 | +ARG LUA_VERSION |
| 24 | +ARG LUAROCKS_VERSION |
| 25 | + |
| 26 | +RUN apt-get update \ |
| 27 | + && apt-get install -y wget build-essential libreadline-dev openssl unzip libncurses-dev libpcre3-dev libssl-dev zlib1g-dev |
| 28 | + |
| 29 | +# Lua build |
| 30 | +ADD ./scripts/build-lua /tmp/build-lua |
| 31 | +RUN /tmp/build-lua |
| 32 | + |
| 33 | +# Nginx build |
| 34 | +ADD ./scripts/build-openresty /tmp/build-openresty |
| 35 | +RUN /tmp/build-openresty |
| 36 | + |
| 37 | +############# |
| 38 | +# Final Image |
| 39 | +############# |
| 40 | + |
| 41 | +FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:stable-slim |
| 42 | +LABEL maintainer="Jamie Curnow <jc@jc21.com>" |
| 43 | + |
| 44 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 45 | + |
| 46 | +# Env var for bashrc |
| 47 | +ARG OPENRESTY_VERSION |
| 48 | +ENV OPENRESTY_VERSION=${OPENRESTY_VERSION} |
| 49 | + |
| 50 | +ARG TARGETPLATFORM |
| 51 | +RUN echo "Base: debian:stable-slim, ${TARGETPLATFORM:-linux/amd64}" > /built-for-arch |
| 52 | + |
| 53 | +# OpenResty uses LuaJIT which has a dependency on GCC |
| 54 | +RUN apt-get update \ |
| 55 | + && apt-get install -y curl figlet openssl libpcre3 zlib1g apache2-utils tzdata perl libreadline7 unzip libncurses6 make gcc \ |
| 56 | + && apt-get clean \ |
| 57 | + && rm -rf /var/lib/apt/lists/* |
| 58 | + |
| 59 | +ADD ./files/.bashrc /root/.bashrc |
| 60 | + |
| 61 | +# Copy lua and luarocks builds from first image |
| 62 | +COPY --from=builder /tmp/lua /tmp/lua |
| 63 | +COPY --from=builder /tmp/luarocks /tmp/luarocks |
| 64 | +ADD ./scripts/install-lua /tmp/install-lua |
| 65 | + |
| 66 | +# Copy openresty build from first image |
| 67 | +COPY --from=builder /tmp/openresty /tmp/openresty |
| 68 | +ADD ./scripts/install-openresty /tmp/install-openresty |
| 69 | + |
| 70 | +# Copy golang built packages |
| 71 | +COPY --from=go /bin/mkcert /bin/mkcert |
| 72 | +COPY --from=go /go/bin/dbmate /bin/dbmate |
| 73 | + |
| 74 | +RUN /tmp/install-lua \ |
| 75 | + && /tmp/install-openresty \ |
| 76 | + && rm -f /tmp/install-lua \ |
| 77 | + && rm -f /tmp/install-openresty \ |
| 78 | + && apt-get remove -y make gcc \ |
| 79 | + && apt-get autoremove -y |
| 80 | + |
| 81 | +LABEL org.label-schema.schema-version="1.0" \ |
| 82 | + org.label-schema.license="MIT" \ |
| 83 | + org.label-schema.name="nginx-full" \ |
| 84 | + org.label-schema.description="A base image for use by Nginx Proxy Manager" \ |
| 85 | + org.label-schema.url="https://github.com/jc21/docker-nginx-full" \ |
| 86 | + org.label-schema.vcs-url="https://github.com/jc21/docker-nginx-full.git" \ |
| 87 | + org.label-schema.cmd="docker run --rm -ti jc21/nginx-full:latest" |
0 commit comments