11ARG BUILD_ENV=git
2- FROM docker.io/openresty/openresty:alpine-fat as with_deps
2+
3+ FROM docker.io/openresty/openresty:alpine-fat AS with_deps
34RUN luarocks install lua-resty-http 0.17.1-0
45
5- FROM with_deps as git
6- ARG BUILD_ENV=git
6+ FROM with_deps AS git
77ARG LUA_LIB_VERSION=v1.0.11
8- RUN if [ "$BUILD_ENV" == "git" ]; then apk add --no-cache git; fi
9- RUN if [ "$BUILD_ENV" == " git" ]; then git clone -b "${LUA_LIB_VERSION}" https://github.com/crowdsecurity/lua-cs-bouncer.git ; fi
8+ RUN apk add --no-cache git
9+ RUN git clone -b "${LUA_LIB_VERSION}" https://github.com/crowdsecurity/lua-cs-bouncer.git /lua-cs-bouncer
1010
11- FROM with_deps as local
12- RUN if [ "$BUILD_ENV" == "local" ]; then COPY ./lua-cs-bouncer/ lua-cs-bouncer; fi
11+ FROM with_deps AS local
12+ COPY lua-cs-bouncer/ /lua-cs-bouncer/
13+
14+ FROM ${BUILD_ENV} AS final
15+ # (optional, if you want to use it in RUN steps)
16+ ARG BUILD_ENV
1317
14- FROM ${BUILD_ENV}
1518RUN mkdir -p /etc/crowdsec/bouncers/ /var/lib/crowdsec/lua/templates/
16- RUN cp -R lua-cs-bouncer/lib/* /usr/local/openresty/lualib/
17- RUN cp -R lua-cs-bouncer/templates/* /var/lib/crowdsec/lua/templates/
18- RUN cp lua-cs-bouncer/config_example.conf /etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf
19- RUN rm -rf ./lua-cs-bouncer/
20- COPY ./openresty /tmp
19+ RUN cp -R /lua-cs-bouncer/lib/* /usr/local/openresty/lualib/
20+ RUN cp -R /lua-cs-bouncer/templates/* /var/lib/crowdsec/lua/templates/
21+ RUN cp /lua-cs-bouncer/config_example.conf /etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf
22+ RUN rm -rf /lua-cs-bouncer
23+
24+ COPY openresty /tmp
2125RUN SSL_CERTS_PATH=/etc/ssl/certs/ca-certificates.crt envsubst '$SSL_CERTS_PATH' < /tmp/crowdsec_openresty.conf > /etc/nginx/conf.d/crowdsec_openresty.conf
2226RUN sed -i '1 i\r esolver local=on ipv6=off;' /etc/nginx/conf.d/crowdsec_openresty.conf
23- COPY ./ docker/docker_start.sh /
27+ COPY docker/docker_start.sh /
2428
25- ENTRYPOINT ["/bin/sh" , "docker_start.sh" ]
29+ ENTRYPOINT ["/bin/sh" , "docker_start.sh" ]
0 commit comments