Pass path to command dynamically in Dockerfile

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 20:18:04 -07:00
parent 6fdf68fcfc
commit 458ea4c16b
2 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,8 @@
FROM openresty/openresty:1.27.1.2-0-bookworm-buildpack FROM openresty/openresty:1.27.1.2-0-bookworm-buildpack
WORKDIR /opt/app
RUN apt-get update && apt-get install -y python3-pygments
RUN luarocks install sitegen RUN luarocks install sitegen
CMD ["openresty", "-p", "/opt/", "-g", "daemon off;"] CMD ["sh", "-c", "openresty -p `pwd` -g 'daemon off;'"]

View File

@ -43,11 +43,11 @@
### build site ### build site
$ docker run --rm -w /opt -v $PWD:/opt sitegen-openresty sitegen $ docker run --rm -w /opt/app -v $PWD:/opt/app sitegen-openresty sitegen
### start server container ### start server
$ docker run --rm -it --init -w /opt -v $PWD:/opt -p 8080:8080 sitegen-openresty $ docker run --rm -it --init -v $PWD:/opt/app -p 8080:8080 sitegen-openresty
### visit `localhost:8080` in web browser ### visit `localhost:8080` in web browser