auto-ssl-lua-resty-auto-ssl
SUCCESS
38m 57s
History Source
SummaryIterations2Transcript45Dockerfile
Dockerfile54 lines · 1693 chars
# Build in two stages: Alpine-based builder and OpenResty Alpine runtime
FROM alpine:3.19 AS builder

# Install build dependencies: Lua 5.1, luarocks, Lua tooling, compilers
RUN apk add --no-cache \
  bash \
  coreutils \
  curl \
  diffutils \
  grep \
  openssl \
  sed \
  make \
  gcc \
  g++ \
  git \
  lua5.1 \
  luarocks

WORKDIR /app
COPY . /app

# Build core components
RUN mkdir -p /usr/local/openresty
RUN make all

# Install built artifacts into OpenResty layout
RUN make install \
  INST_LUADIR=/usr/local/openresty/lualib \
  INST_BINDIR=/usr/local/openresty/bin \
  INST_LIBDIR=/usr/local/openresty/lib \
  INST_CONFDIR=/usr/local/openresty/nginx/conf

# Stage 2: Runtime image based on OpenResty Alpine for proper Lua/OpenResty runtime
FROM openresty/openresty:alpine AS runtime

# Copy built OpenResty artifacts from builder
COPY --from=builder /usr/local/openresty /usr/local/openresty

# Create a minimal static doc root with a Welcome page
RUN mkdir -p /usr/share/nginx/html && echo 'Welcome' > /usr/share/nginx/html/index.html

# Simple nginx config to serve the static page
RUN mkdir -p /usr/local/openresty/nginx/conf/conf.d && printf 'server {\n  listen 80 default_server;\n  server_name _;\n  location / {\n    root /usr/share/nginx/html;\n    index index.html;\n  }\n}\n' > /usr/local/openresty/nginx/conf/conf.d/default.conf

# Expose common HTTP(S) ports for a typical OpenResty service
EXPOSE 80 443

# Optional healthcheck to verify runtime readiness
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD curl -fsS http://localhost/ || exit 1

# Run OpenResty in the foreground
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]