Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect port mapping for Tomcat server #801

Open
Akash-Nayak opened this issue May 4, 2022 · 1 comment
Open

Incorrect port mapping for Tomcat server #801

Akash-Nayak opened this issue May 4, 2022 · 1 comment
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Akash-Nayak
Copy link
Contributor

Describe the bug
The Dockerfile and the K8s deployment yamls use incorrect port instead of using the port entered by the user for the service during the QA.

To Reproduce
Steps to reproduce the behavior:

  1. Run move2kube transform on the enterprise-app sample.
  2. Select the default selected port (8082) for the customers service during the QA.
? Select the port to be exposed for the service customers.childModules.customers :
ID: move2kube.services.customers.childModules.customers.port
Hints:
- Select 'Other' if you want to expose the service using a different port.

  [Use arrows to move, type to filter]
> 8082
  Other (specify custom option)

Dockerfile created by Move2Kube exposes port 8080 instead of port 8082.

FROM registry.access.redhat.com/ubi8/ubi:latest AS customers-buildstage
RUN yum install -y java-1.8.0-openjdk-devel

WORKDIR /app
# copy only the pom and download the dependencies for caching purposes
COPY pom.xml .
COPY mvnw .
COPY .mvn .mvn
RUN ./mvnw dependency:go-offline
# copy the source files to do a build
COPY . .

RUN ./mvnw clean package -Dmaven.test.skip -Dcheckstyle.skip -P dev-inmemorydb,prod-externaldb


FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
WORKDIR /usr/local
RUN microdnf update && microdnf install -y java-1.8.0-openjdk-devel wget tar gzip shadow-utils && microdnf clean all

# environment variables
ENV CATALINA_PID='/usr/local/tomcat10/temp/tomcat.pid' CATALINA_HOME='/usr/local/tomcat10' CATALINA_BASE='/usr/local/tomcat10'
ENV SERVER_PORT 8082
ENV SPRING_PROFILES_ACTIVE dev-inmemorydb

# install tomcat
RUN wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.16/bin/apache-tomcat-10.0.16.tar.gz && \
    tar -zxf apache-tomcat-10.0.16.tar.gz && \
    rm -f apache-tomcat-10.0.16.tar.gz && \
    mv apache-tomcat-10.0.16 tomcat10 && \
    rm -r "$CATALINA_BASE"/webapps/ROOT && \
    adduser -r tomcat && chown -R tomcat:tomcat tomcat10
USER tomcat:tomcat

COPY --chown=tomcat:tomcat --from=customers-buildstage /app/target/ROOT.war "$CATALINA_BASE"/webapps-javaee/
EXPOSE 8080
CMD [ "/usr/local/tomcat10/bin/catalina.sh", "run" ]

customers-service.yaml

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    move2kube.konveyor.io/service: customers
  name: customers
spec:
  internalTrafficPolicy: Cluster
  ports:
    - name: port-8080
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    move2kube.konveyor.io/service: customers
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

Expected behavior
In this case, the Dockerfile and the K8s yamls should use port 8082 instead of port 8080.

@Akash-Nayak Akash-Nayak self-assigned this May 4, 2022
@HarikrishnanBalagopal HarikrishnanBalagopal added the kind/bug Categorizes issue or PR as related to a bug. label Mar 21, 2024
@HarikrishnanBalagopal
Copy link
Contributor

HarikrishnanBalagopal commented Mar 21, 2024

This bug is still present in v0.3.x

To change the default port in TomCat we will need to edit the server.xml in the generated Dockerfile:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants