onpremises icon indicating copy to clipboard operation
onpremises copied to clipboard

Can we make docker port image configurable?

Open dzharikhin opened this issue 2 years ago • 4 comments

Description

We have to run the container in host network mode, so we cannot remap 8080

Priority

I have no budget and there's no rush, please add this feature for free

More information

I can prepare PR if it is convenient. In fact changes required are small

dzharikhin avatar Apr 08 '24 10:04 dzharikhin

I don't think any code changes to the repo are necessary for you to facilitate this change on your own. I confirmed this works in a sandbox.

Change the Dockerfile from this:

FROM tomcat:10.1.16-jre17-temurin-jammy

RUN set -eux; \
	apt-get update; \
	apt-get install -y --no-install-recommends graphviz

RUN sed -i 's/port="8080"/port="8080" maxPostSize="10485760"/' conf/server.xml

ADD build/libs/structurizr-onpremises.war /usr/local/tomcat/webapps/ROOT.war

ENV CATALINA_OPTS="-Xms512M -Xmx512M"
EXPOSE 8080

CMD ["catalina.sh", "run"]

To This (Assuming desiring port 8282 instead of 8080):

FROM tomcat:10.1.16-jre17-temurin-jammy

RUN set -eux; \
	apt-get update; \
	apt-get install -y --no-install-recommends graphviz

RUN sed -i 's/port="8080"/port="8080" maxPostSize="10485760"/' conf/server.xml
RUN sed -i 's/port="8080"/port="8282"/' conf/server.xml

ADD build/libs/structurizr-onpremises.war /usr/local/tomcat/webapps/ROOT.war

ENV CATALINA_OPTS="-Xms512M -Xmx512M"
EXPOSE 8282

CMD ["catalina.sh", "run"]

Sn3akyP3t3 avatar Apr 24 '24 21:04 Sn3akyP3t3

Yes, the diff can switch the app to another hardcoded port. Thank you.But to make this work:

  1. You need to build and support your own image of structurizr
  2. The port remains to be hardcoded in the image. You can't override it on container start

dzharikhin avatar Apr 26 '24 08:04 dzharikhin

I'd be interested to see what your solution to this problem is. I suggest you proceed with the PR you proposed.

Sn3akyP3t3 avatar Apr 26 '24 14:04 Sn3akyP3t3

I tested the scheme with variable substitution

dzharikhin avatar Apr 27 '24 14:04 dzharikhin

any update?

dzharikhin avatar Jun 05 '24 15:06 dzharikhin

I've made the port configurable via an environment variable named PORT and the built-in setenv.sh mechanism, which gets sourced inside catalina.sh. Thanks for the PR though.

simonbrowndotje avatar Jul 03 '24 15:07 simonbrowndotje