Pass path to command dynamically in Dockerfile

This commit is contained in:
Catalin Constantin Mititiuc 2025-05-10 12:11:36 -07:00
parent 2a9a39ac6d
commit b5771c94c9
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
WORKDIR /opt/app
RUN apt-get update && apt-get install -y python3-pygments
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
$ 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