eclipse-che / che

Kubernetes based Cloud Development Environments for Enterprise Teams
http://eclipse.org/che
Eclipse Public License 2.0
6.99k stars 1.19k forks source link

Setting $CATALINA_HOME Environment-Variable makes Tomcat start at Workspace start #6078

Closed robbirob closed 7 years ago

robbirob commented 7 years ago

I am not sure if this is intentional or not.

Setting $CATALINA_HOME starts the Tomcat-Server automatically on Workspace startup.

Since Tomcat needs some artifacts i need to build before i start tomcat, tomcat fails because they aren't available at workspace start. A failing tomcat startup makes the whole workspace startup fail.

Is there a possibility to set CATALINA_HOME and have tomcat not start with the workspace?

OS and version:
Mint Linux 18.1

Diagnostics: WARNING: No swap limit support INFO: (che cli): 5.16.0 - using docker 17.06.1-ce / native

CLI: TTY: true Daemon: /var/run/docker.sock Image: eclipse/che:5.16.0 Version: 5.16.0 Command: info Parameters: info Mounts: /data: /data /data/instance: not set /data/backup: not set /repo: not set /assembly: not set /sync: not set /unison: not set /chedir: not set System: Docker: native Proxy: not set Internal: CHE_VERSION: 5.16.0 CHE_HOST: 10.131.200.11 CHE_INSTANCE: /data/instance CHE_CONFIG: /data CHE_BACKUP: /data/backup CHE_REGISTRY: /version CHE_DEBUG: false IP Detection: 10.131.200.11 Initialized: true Image Registry: IMAGE_INIT=eclipse/che-init:5.16.0 IMAGE_CHE=eclipse/che-server:5.16.0 IMAGE_COMPOSE=docker/compose:1.8.1 IMAGE_TRAEFIK=traefik:v1.3.0-rc3 BOOTSTRAP_IMAGE_ALPINE=alpine:3.4 BOOTSTRAP_IMAGE_CHEIP=eclipse/che-ip:5.16.0 UTILITY_IMAGE_CHEACTION=eclipse/che-action:5.16.0 UTILITY_IMAGE_CHEDIR=eclipse/che-dir:5.16.0 UTILITY_IMAGE_CHETEST=eclipse/che-test:5.16.0 UTILITY_IMAGE_CHEMOUNT=eclipse/che-mount:5.16.0 che.env: CHE_HOST=10.131.200.11 CHE_SINGLE_PORT=false

ghost commented 7 years ago

@robbirob can you share your Docker recipe? No process should start automatically unless you start it either in entrypoint or CMD.

robbirob commented 7 years ago

The Dockerfile in Question is:

FROM localhost:5000/ubuntu_jdk7_crypto
EXPOSE 8080 22

COPY apache-tomcat-8.0.33.tar.gz /opt
COPY log4j.properties /home/user/conf/
RUN cd /opt && sudo tar -xzf apache-tomcat-8.0.33.tar.gz \
  && sudo rm apache-tomcat-8.0.33.tar.gz

COPY conf /opt/apache-tomcat-8.0.33/conf
COPY keystore /home/user/keystore/
COPY keystore_test /home/user/keystore_test/

RUN sudo chown -R user:user /home/user/keystore \
  /home/user/keystore_test/ \
  /opt/apache-tomcat-8.0.33 \
  /home/user/conf

ENV CATALINA_HOME=/opt/apache-tomcat-8.0.33 \
    MAVEN_VERSION=3.3.9
ENV M2_HOME=/home/user/apache-maven-$MAVEN_VERSION
ENV PATH=$M2_HOME/bin:$PATH

RUN mkdir /home/user/apache-maven-$MAVEN_VERSION && \
  wget -qO- "http://apache.ip-connect.vn.ua/maven/maven-3/$MAVEN_VERSION/ binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C /home/user/apache-maven-$MAVEN_VERSION/

CMD tail -f /dev/null

which inherits from the following Dockerfile:

FROM localhost:5000/ubuntu

COPY jdk-7u80-linux-x64.tar.gz /opt/
COPY UnlimitedJCEPolicyJDK7.zip /opt
RUN cd /opt && sudo tar -xzf jdk-7u80-linux-x64.tar.gz \
  && sudo unzip UnlimitedJCEPolicyJDK7.zip -d /opt \
  && sudo rm jdk-7u80-linux-x64.tar.gz \
  && sudo ln -s jdk1.7.0_80 java \
  && sudo rm UnlimitedJCEPolicyJDK7.zip \
  && sudo cp UnlimitedJCEPolicy/local_policy.jar UnlimitedJCEPolicy/US_export_policy.jar /opt/jdk1.7.0_80/jre/lib/security/ \
  && sudo rm -rf UnlimitedJCEPolicy

ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV JAVA_HOME=/opt/java
ENV PATH=$JAVA_HOME/bin:$PATH

CMD tail -f /dev/null

which inherits from eclipse/stack-base:ubuntu (which i put in my own registry and just called ubuntu)

My recipe is:

services:
  dev-machine:
    image: 'localhost:5000/tomcat8_jdk7'
  db:
    image: eclipse/mysql
    mem_limit: 2147483648
    environment:
      MYSQL_ROOT_PASSWORD: testpw
      MYSQL_DATABASE: WBD
ghost commented 7 years ago

@robbirob what happens if you just use your composefile without Che. Same behavior? I see nothing in the Dockerfile that starts Tomcat.

robbirob commented 7 years ago

I started the compose file without Che. I have the expected behavior, where tomcat does not start automatically. In Che it's starting again as it shouldn't. Changing ENV CATALINA_HOME=/opt/apache-tomcat-8.0.33 to ENV TOMCAT_HOME=/opt/apache-tomcat-8.0.33 in my Dockerfile is fixing this issue.

ghost commented 7 years ago

@robbirob I see now. Yes, CATALINA_HOME is reserved for a workspace agent.