jodconverter / docker-image-jodconverter-examples

Docker image with jodconverter + libreoffice for document conversion through a REST api
https://github.com/sbraconnier/jodconverter
MIT License
72 stars 32 forks source link

application.properties does not applying ? #9

Closed mexekanez closed 4 years ago

mexekanez commented 4 years ago
.......
RUN mkdir -p ${JAR_FILE_BASEDIR} /etc/app \
  && touch /etc/app/application.properties \
  && chmod +x /docker-entrypoint.sh

COPY config/application.properties /etc/app/application.properties

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-Dspring.config.location=/etc/app/application.properties"]
.............

I don't understand why in this case properties can't be applied?

And in general, could you confirm that this option released?

Best regards, Ivan!

EugenMayer commented 4 years ago

Are you building your own image with the statements above or what are you reffering to?

The configuration at /etc/app/application.properties should be picked up, yes

wussup commented 4 years ago

IMHO configuration is not working. @EugenMayer you could try to add an additional line before entrypoint in Dockerfile to test it:

RUN echo "server.port=8090" > /etc/app/application.properties

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-Dspring.config.location=/etc/app/application.properties"]

After running you will see, that application runs on default port 8080.

mexekanez commented 4 years ago

yes, @wussup you got the point. configs don't seem to be working.

only one way - build custom image and adjust .yaml settings before

EugenMayer commented 4 years ago

Please post you entires Dockerfile you build not just some snippets of whatever there might be.

We might have an issue still, but let me invstigate with the informations

wussup commented 4 years ago

@EugenMayer this is your Dockerfile with my echo to application.properties

#  ---------------------------------- setup our needed libreoffice engaged server with newest glibc
# we cannot use the official image since we then cannot have sid and the glibc fix
#FROM openjdk:11.0-jre-slim-stretch as jodconverter-base
FROM debian:sid as jodconverter-base
# backports would only be needed for stretch
#RUN echo "deb http://ftp2.de.debian.org/debian stretch-backports main contrib non-free" > /etc/apt/sources.list.d/debian-backports.list
RUN apt-get update && apt-get -y install \
        openjdk-11-jre \
        apt-transport-https locales-all libpng16-16 libxinerama1 libgl1-mesa-glx libfontconfig1 libfreetype6 libxrender1 \
        libxcb-shm0 libxcb-render0 adduser cpio findutils \
        # procps needed for us finding the libreoffice process, see https://github.com/sbraconnier/jodconverter/issues/127#issuecomment-463668183
        procps \
    # only for stretch
    #&& apt-get -y install -t stretch-backports libreoffice --no-install-recommends \
    # sid variant
    && apt-get -y install libreoffice --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*
ENV JAR_FILE_NAME=app.war
ENV JAR_FILE_BASEDIR=/opt/app
ENV LOG_BASE_DIR=/var/log

COPY bin/docker-entrypoint.sh /docker-entrypoint.sh

RUN mkdir -p ${JAR_FILE_BASEDIR} /etc/app \
  && touch /etc/app/application.properties \
  && chmod +x /docker-entrypoint.sh

RUN echo "server.port=8090" > /etc/app/application.properties

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-Dspring.config.location=/etc/app/application.properties"]

#  ----------------------------------  build our jodconvert builder, so source code with build tools
# TODO: java11 compat yet not given for jodconverter https://github.com/sbraconnier/jodconverter/pull/128
FROM openjdk:11-jdk as jodconverter-builder
RUN apt-get update \
  && apt-get -y install git \
  && git clone https://github.com/sbraconnier/jodconverter /tmp/jodconverter \
  && mkdir /dist

#  ---------------------------------- gui builder
FROM jodconverter-builder as jodconverter-gui
WORKDIR /tmp/jodconverter/jodconverter-samples/jodconverter-sample-spring-boot
RUN ../../gradlew build \
  && cp build/libs/*SNAPSHOT.war /dist/jodconverter-gui.war

#  ----------------------------------  rest build
FROM jodconverter-builder as jodconverter-rest
WORKDIR /tmp/jodconverter/jodconverter-samples/jodconverter-sample-rest
RUN ../../gradlew build \
  && cp build/libs/*SNAPSHOT.war /dist/jodconverter-rest.war

#  ----------------------------------  GUI prod image
FROM jodconverter-base as gui
COPY --from=jodconverter-gui /dist/jodconverter-gui.war ${JAR_FILE_BASEDIR}/${JAR_FILE_NAME}

#  ----------------------------------  REST prod image
FROM jodconverter-base as rest
COPY --from=jodconverter-rest /dist/jodconverter-rest.war ${JAR_FILE_BASEDIR}/${JAR_FILE_NAME}
mexekanez commented 4 years ago

and even more, simplified test version:

FROM eugenmayer/jodconverter:rest
COPY config/application.properties /etc/app/application.properties
wussup commented 4 years ago

@EugenMayer @mexekanez guys, please check fix.

mexekanez commented 4 years ago

@wussup does it working for you?

wussup commented 4 years ago

@mexekanez yes, this example starts on port 8090 as specified in application.properties :

#  ---------------------------------- setup our needed libreoffice engaged server with newest glibc
# we cannot use the official image since we then cannot have sid and the glibc fix
#FROM openjdk:11.0-jre-slim-stretch as jodconverter-base
FROM debian:sid as jodconverter-base
# backports would only be needed for stretch
#RUN echo "deb http://ftp2.de.debian.org/debian stretch-backports main contrib non-free" > /etc/apt/sources.list.d/debian-backports.list
RUN apt-get update && apt-get -y install \
        openjdk-11-jre \
        apt-transport-https locales-all libpng16-16 libxinerama1 libgl1-mesa-glx libfontconfig1 libfreetype6 libxrender1 \
        libxcb-shm0 libxcb-render0 adduser cpio findutils \
        # procps needed for us finding the libreoffice process, see https://github.com/sbraconnier/jodconverter/issues/127#issuecomment-463668183
        procps \
    # only for stretch
    #&& apt-get -y install -t stretch-backports libreoffice --no-install-recommends \
    # sid variant
    && apt-get -y install libreoffice --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*
ENV JAR_FILE_NAME=app.war
ENV JAR_FILE_BASEDIR=/opt/app
ENV LOG_BASE_DIR=/var/log

COPY bin/docker-entrypoint.sh /docker-entrypoint.sh

RUN mkdir -p ${JAR_FILE_BASEDIR} /etc/app \
  && touch /etc/app/application.properties \
  && chmod +x /docker-entrypoint.sh

RUN echo "server.port=8090" > /etc/app/application.properties

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["--spring.config.additional-location=/etc/app/"]

#  ----------------------------------  build our jodconvert builder, so source code with build tools
# TODO: java11 compat yet not given for jodconverter https://github.com/sbraconnier/jodconverter/pull/128
FROM openjdk:11-jdk as jodconverter-builder
RUN apt-get update \
  && apt-get -y install git \
  && git clone https://github.com/sbraconnier/jodconverter /tmp/jodconverter \
  && mkdir /dist

#  ---------------------------------- gui builder
FROM jodconverter-builder as jodconverter-gui
WORKDIR /tmp/jodconverter/jodconverter-samples/jodconverter-sample-spring-boot
RUN ../../gradlew build \
  && cp build/libs/*SNAPSHOT.war /dist/jodconverter-gui.war

#  ----------------------------------  rest build
FROM jodconverter-builder as jodconverter-rest
WORKDIR /tmp/jodconverter/jodconverter-samples/jodconverter-sample-rest
RUN ../../gradlew build \
  && cp build/libs/*SNAPSHOT.war /dist/jodconverter-rest.war

#  ----------------------------------  GUI prod image
FROM jodconverter-base as gui
COPY --from=jodconverter-gui /dist/jodconverter-gui.war ${JAR_FILE_BASEDIR}/${JAR_FILE_NAME}

#  ----------------------------------  REST prod image
FROM jodconverter-base as rest
COPY --from=jodconverter-rest /dist/jodconverter-rest.war ${JAR_FILE_BASEDIR}/${JAR_FILE_NAME}
wussup commented 4 years ago

Also tested in the test environment of my application, now everything is ok, waiting for your feedback.

wussup commented 4 years ago

Here is explanation https://stackoverflow.com/a/47210661/4141492

EugenMayer commented 4 years ago

Sorry, took me a while. Thank you for digging that one out and correcting it!