From ca2341528848befea8441c0c341e1293eed19e95 Mon Sep 17 00:00:00 2001 From: xananax Date: Thu, 22 May 2025 11:25:21 +0200 Subject: [PATCH] feat: allow containerized deployments At the moment, it seems like it should be working, but I get: ``` lua5.1: error loading module 'bcrypt' from file '/usr/local/openresty/luajit/lib/lua/5.1/bcrypt.so': Error relocating /usr/local/openresty/luajit/lib/lua/5.1/bcrypt.so: luaL_setfuncs: symbol not found ``` --- docker-compose.yaml | 13 +++++++++++++ dockerfile | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docker-compose.yaml create mode 100644 dockerfile diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9f04b30 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +# Generate a random secret key +# export PROD_SECRET_KEY=$(openssl rand -hex 32) +# Start the container +# docker-compose up +version: "3" +services: + porom: + build: + context: . + args: + - PROD_SECRET_KEY=${PROD_SECRET_KEY} + ports: + - "8080:8080" \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..4b01a6c --- /dev/null +++ b/dockerfile @@ -0,0 +1,36 @@ +# HOW TO: +# +# Generate a random secret key & build the Docker image +# ```sh +# SECRET_KEY=$(openssl rand -hex 32) docker build --build-arg PROD_SECRET_KEY="$SECRET_KEY" -t porom:latest . +# ``` +# +# Then run the container +# ```sh +# docker run -d -p 8080:8080 --name porom porom:latest +# ``` +# +FROM openresty/openresty:alpine-fat +COPY ./nginx.conf /usr/local/openresty/nginx/conf/nginx.conf +COPY . /usr/local/openresty/nginx/html +WORKDIR /usr/local/openresty/nginx/html +RUN apk add --no-cache \ + make \ + git \ + make \ + gcc \ + g++ \ + musl-dev \ + libffi-dev \ + openssl-dev \ + sqlite-dev \ + imagemagick-dev \ + lua5.1 \ + lua5.1-dev +RUN eval "$(luarocks --lua-version 5.1 path)" +RUN luarocks --lua-version 5.1 build --only-deps +ARG PROD_SECRET_KEY +RUN echo "return { key = \"${PROD_SECRET_KEY}\",}" > /usr/local/openresty/nginx/html/secrets.lua +EXPOSE 8080 +RUN chmod +x /usr/local/openresty/nginx/html/start.sh +ENTRYPOINT ["/usr/local/openresty/nginx/html/start.sh", "production"] \ No newline at end of file