# Java Spring Stack

The example below demonstrates a Spring stack sample `docker-compose.yml` with the pre-defined Sidecar.

<img src="https://3706867246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0tGo33otNRgIhFn6lpgU%2Fuploads%2FO2RXiTfjPOkdSJkP1fYa%2Fjava.png?alt=media&#x26;token=0cc7bff0-6d5f-46ec-8868-dd54339b7d6e" alt="" data-size="line"><img src="https://3706867246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0tGo33otNRgIhFn6lpgU%2Fuploads%2FTif22cqD4xeTVmyvX9nk%2Fspring-boot.png?alt=media&#x26;token=e197ec7e-a147-4243-b2ae-db3a2da579fc" alt="" data-size="line"><img src="https://3706867246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0tGo33otNRgIhFn6lpgU%2Fuploads%2FP2to0MQLC4q5HbZLTCnY%2Ficons8-react-30.png?alt=media&#x26;token=95fe774a-4549-4240-a753-25a85914ea9f" alt="" data-size="line">

{% code title="docker-compose.yml" %}

```docker
# Spring Stack docker-compose file example
version: '3.8'

# Define services
services:
  # App backend service
  app-server:
    build:
      context: app-server 
      dockerfile: Dockerfile
    ports:
      - "8080:8080" 
    restart: always
    depends_on: 
      - db 
    environment: 
      SPRING_DATASOURCE_URL: jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example
      SPRING_DATASOURCE_USERNAME: my-user
      SPRING_DATASOURCE_PASSWORD: my-password     

  # Frontend Service 
  app-client:
    build:
      context: app-client 
      dockerfile: Dockerfile
      args:
        REACT_APP_API_BASE_URL: https://ip:8080/api
    ports:
      - "80:80" 
    restart: always
    depends_on:
      - app-server

  # Database Service (MySQL)
  db:
    image: mysql:5.7
    ports:
      - "3306:3306"
    restart: always
    environment:
      MYSQL_DATABASE: db
      MYSQL_USER: my-db-user
      MYSQL_PASSWORD: my-db-password
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - db-data:/var/lib/mysql
    
  sidecar:
    image: industryapps.azurecr.io/service-discovery-sidecar
    container_name: { my-apps-name-sidecar }
    restart: always
    environment:
      NODE_ENV: production
      DEPLOYMENT_MODE: public
      EUREKA_INSTANCE_IP: { IP }
      EUREKA_INSTANCE_PORT: { PORT }
      EUREKA_INSTANCE_APP: { app-code }
      EUREKA_INSTANCE_HOST_NAME: { my-app-domain }/
      EUREKA_INSTANCE_HOME_PAGE_URL: https://<your_domain>/{APPCODE}
      EUREKA_HOST: servicediscovery.uat.industryapps.net
      EUREKA_PORT: 443
      
volumes:
  db-data:

networks:
   default:
      driver: bridge
```

{% endcode %}

Inside the `docker-compose.yml` file, add the necessary information which is tagged with curly braces ' `{  }` '.&#x20;

* **`IP`** -> The IP of the web service which you are running, such as on AWS EC2 Ubuntu, Lightsail instance or Azure Web services as an example.
* **`PORT`** -> The port which the app client-side is served at (e.g. Port 80).
* **`APPCODE`** -> Navigate to Developer dashboard > Applications > {App Name} > App Data, the Application code will be available there.
* **`HOSTNAME`** -> Can be found on the Developer dashboard, the boilerplate is the hostname  of the application: `https://<your_domain>/{APPCODE}`

{% hint style="info" %}
If the application container is pushed onto IndustryApps, the HOSTNAME is the Application ID.
{% endhint %}

[Additional information about Production deployment can be found here.](https://docs.industryapps.net/connect-to-the-platform/production-deployment)
