nginx/Dockerfile.alpine

57 lines
1.4 KiB
Docker

# 1.22.1 Alpine 3.17
# 1.24.0 Alpine 3.19
# 1.26.2 Alpine 3.21
ARG ALPINE_VERSION=3.21
FROM docker.io/aprimediet/alpine:${ALPINE_VERSION} AS builder
LABEL maintainer="<Muhamad Aditya Prima> aprimediet@gmail.com"
USER root
ENV NGINX_ROOT_DIR=/app
# Add nginx user and group and install nginx
RUN /usr/sbin/addgroup -g 10001 nginx; \
/usr/sbin/adduser -D -u 10001 -G nginx -s /sbin/nologin -h ${NGINX_ROOT_DIR}/htdocs nginx; \
/sbin/apk --no-cache upgrade; \
/sbin/apk --no-cache --update add \
nginx;
# Required files
ADD ./etc/nginx /etc/nginx
ADD ./scripts/entrypoint.sh /usr/local/bin/
ADD ./htdocs /app/htdocs
RUN /bin/chmod +x /usr/local/bin/entrypoint.sh; \
/bin/chown -R nginx:nginx /app ; \
/sbin/apk del curl ; \
/bin/rm -rf /var/cache/apk/* ;
FROM scratch
ARG NGINX_VERSION=1.26
ENV NGINX_VERSION=${NGINX_VERSION}
LABEL maintainer="Muhamad Aditya Prima <aprimediet@gmail.com>"
LABEL name="nginx"
LABEL version="${NGINX_VERSION}"
LABEL distribution-scope="public"
#labels for container catalog
LABEL summary="Nginx ${NGINX_VERSION} on alpine based container image"
LABEL description="Provide nginx on alpine based container base image"
LABEL io.k8s.description="Very small alpine linux container image"
LABEL io.k8s.display-name="Nginx ${NGINX_VERSION}"
COPY --from=builder / /
USER nginx
WORKDIR /app/htdocs
EXPOSE 80
STOPSIGNAL SIGQUIT
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]