'Tomcat Is not Starting after Github Actions pipeline

I'm using a self-hosted GitHub Actions Runner to deploy a small Java application.

The runner is inside a Docker container, that I created using a Dockerfile:

FROM ubuntu:18.04
LABEL Author="***"

ARG GH_ACTIONS_RUNNER_VERSION=2.290.1

RUN apt-get -y update && \
    apt-get install -y wget && \
    apt-get install -y curl && \
    apt-get install -y git && \
    apt-get install -y sudo && \
    apt-get install -y net-tools && \
    apt-get install -y maven

# GITHUB ACTIONS RUNNER
RUN curl -o actions-runner-linux-x64.tar.gz -L "https://github.com/actions/runner/releases/download/v${GH_ACTIONS_RUNNER_VERSION}/actions-runner-linux-x64-${GH_ACTIONS_RUNNER_VERSION}.tar.gz" \
    && tar xzf ./actions-runner-linux-x64.tar.gz \
    && rm -f actions-runner-linux-x64.tar.gz

# TOMCAT
EXPOSE 8080
RUN cd tmp && \
    wget "http://apache.uvigo.es/tomcat/tomcat-9/v9.0.62/bin/apache-tomcat-9.0.62.tar.gz" && \
    tar -zxvf /tmp/apache-tomcat-9.0.62.tar.gz -C /usr/local && \
    cd /usr/local && mv apache-tomcat-9.0.62 tomcat && \
    cd /tmp && rm -rf *

# MYSQL
EXPOSE 3306
RUN sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server

# PHANTOMJS
RUN cd tmp && \
    wget "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2" && \
    tar xvjf /tmp/phantomjs-2.1.1-linux-x86_64.tar.bz2 && \
    mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin && \
    rm -rf *


CMD  sudo usermod -d /var/lib/mysql/ mysql && sudo service mysql start && sh /usr/local/tomcat/bin/catalina.sh start && /bin/bash

And I'm using the following main.yaml file to execute the pipelines:

name: CI

on:

  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
   
  pruebas-unitarias:
    runs-on: self-hosted
    steps:
      - name: Checkout repository
        uses: actions/[email protected]
      - name: Unit Tests
        run: mvn test

  empaquetar:
    runs-on: self-hosted
    needs: pruebas-unitarias
    steps:
      - name: build
        run: mvn package -DskipTests=true
      - name: upload-artifact
        uses: actions/upload-artifact@v3
        with:
          name: baloncesto
          path: target/

  pruebas-funcionales:
    runs-on: self-hosted
    needs: empaquetar
    steps:
      - run: cp -r target/Baloncesto /usr/local/tomcat/webapps
      - run: mysql -u root < db/baloncesto.sql
      - run: export DATABASE_HOST="jdbc:mysql://localhost"
      - run: export DATABASE_PORT="3306"
      - run: export DATABASE_NAME="baloncesto"
      - run: export DATABASE_USER="usuario"
      - run: export DATABASE_PASS="clave"
      - run: sh /usr/local/tomcat/bin/catalina.sh stop
      - run: sh /usr/local/tomcat/bin/catalina.sh start

However, after the pipeline executes, it is supposed to run the tomcat server on port 8080,but it's not.

Inside the pipeline when I stop the tomcat server with "sh /usr/local/tomcat/bin/catalina.sh stop" the ports look like this:

Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN     
tcp        0      0 172.17.0.3:42844        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42882        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42804        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42814        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42822        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42858        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42852        13.107.42.16:443        TIME_WAIT  
tcp        0      0 127.0.0.1:52434         127.0.0.1:8005          TIME_WAIT

And when I start it with "sh /usr/local/tomcat/bin/catalina.sh start" the ports looks like this:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN     
tcp        0      0 172.17.0.3:42844        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42882        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42934        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42914        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42918        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42836        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42872        13.107.42.16:443        TIME_WAIT  
tcp        0      0 172.17.0.3:42840        13.107.42.16:443        TIME_WAIT  
tcp        0      0 127.0.0.1:52434         127.0.0.1:8005          TIME_WAIT

And then, on the container, after the pipeline is executed, the ports are like this:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp6       0      0 172.17.0.3:42322        13.107.42.16:443        ESTABLISHED

Only the Mysql server is running. I don't know what is happening...

Pd: The tomcat server was already started before the pipeline. We need to stop and start the server again in order to set the Database variables.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source