Try WSO2 Cloud for Free
Sign in

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Rename docker domain used in Integration Cloud.

...

  1. Create an archive file by bundling your application's artifacts together.

    Expand
    titleExpand to see the archive file types for different app types...
     App Type Archive File Type
    WSO2 ESB Composite Application.car
    Ballerina Service.bsz
    Java Web Appplication.war
    Java Microservice.jar
    PHP Application.zip Note that when creating the ZIP file, you must select all your application's artifacts (Alt+A), right-click on the selected files, and then click Archive or any other option depending on your operating system or software.
    WSO2 Jaggery Application.zip Note that when creating the ZIP file, you must select all your application's artifacts (Alt+A), right-click on the selected files, and then click Archive or any other option depending on your operating system or software.
    WSO2 Data Service.car (see this for more information).

    Let's set up your local environment using a Docker image of the Cloud's runtime in which you plan to deploy your application. 

    Docker is a tool designed to make it easier to create, deploy, and run applications using containers, which allow you to package your application with the required libraries and dependencies. Because of containers, your application will run on any machine regardless of the customized settings that each machine might have that could differ from the machine used for writing and testing the code.

  2. WSO2 Cloud offers runtimes for each application type that you can deploy in the Cloud. The runtimes have corresponding Docker images as shown in the table below. Select a Docker image from the list:

    Tip

    Tip: Note that the runtimes that are deprecated in WSO2 Cloud do not have corresponding Docker images.

    Expand
    titleExpand to see the Docker images for different runtimes...
  3. Install Docker 1.10.3 on your developer environment by following the instructions here.
  4. Create a folder for your application in an appropriate location.

    Code Block
    mkdir -p /home/user/dev/foo-app
  5. Create a Dockerfile with the name Dockerfile inside the folder mentioned above.

  6. Click the link below and select the Docker file content that goes with the application type that you want to deploy. 

    Tip

    Tip: It is recommended to use environment variables in your application when defining variables such as database URLs, database users, etc. This will ensure that you do not have to change the code when running your application on different platforms such as the Docker image and the Cloud.

    Expand
    titleExpand this to see the Docker file content for your app type...
    App TypeDocker File Content
    WSO2 ESB Composite Application
    Code Block
    FROM docker.cloud.wso2.com/wso2-cloud/wso2esb:5.0.0-alpine3.4-oracle-jdk1.8.0
    
    ENV CARBON_HOME_PATH /home/wso2user/wso2esb-5.0.0
    ENV TENANT_ID 1
    ENV TENANT_DOMAIN wso2samples
    ENV CREATE_TENANT true
    ENV CAR_DEPLOYMENT_DIR $CARBON_HOME_PATH/repository/tenants/$TENANT_ID/carbonapps/
    ENV TOTAL_MEMORY 1024
    ENV CAR_FILE <APP_ARTIFACT_NAME>
    
    RUN mkdir -p $CAR_DEPLOYMENT_DIR
    
    COPY $CAR_FILE $CARBON_HOME_PATH/repository/tenants/$TENANT_ID/carbonapps
    WORKDIR "/"
    CMD ["bash", "-c", "source /init.sh"]
    Ballerina Service<Coming up soon>
    Java Web Application
    Code Block
    FROM <DOCKER_IMAGE>
    
    ENV APP_WAR <APP_ARTIFACT_NAME>
    ENV WEB_APP_HOME $TOMCAT_HOME_DIR/webapps/
    ENV TOTAL_MEMORY 512
    ENV TAIL_LOG ENABLE_TAIL_LOG
    
    COPY "$APP_WAR" "$WEB_APP_HOME/"
    
    CMD ["bash", "-c", "source /init.sh"]
    Tip

    Tip: <DOCKER_IMAGE> in this command can have one of many values you see in the table in step 2.

    Java Microservice 2.0.0
    Code Block
    FROM docker.cloud.wso2.com/wso2-cloud/msf4j:2.0.0-alpine3.4-oracle-jdk1.8.0
    
    ENV MSF4J_JAR  <APP_ARTIFACT_NAME>
    COPY "$MSF4J_JAR" "$MSF4J_HOME/"
    ENV TOTAL_MEMORY 256
    
    CMD ["bash", "-c", "source /init.sh"]
    Tip

    Tip: Be sure to pull the Docker image that corresponds to the runtime you plan to select in WSO2 Cloud. For example, if you plan to select MSF4J 1.0.0, which is deprecated, as your runtime in the Cloud, the given Docker image will not be compatible as it is based on MSF4J 2.0.0.

    PHP
    Code Block
    FROM docker.cloud.wso2.com/wso2-cloud/php:7.0.4-debian8-apache2.4.10
    
    ENV PHP_APP_ZIP <APP_ARTIFACT_NAME>
    ENV UPLOAD_PATH /tmp/src
    ENV WEB_ROOT /var/www/html/
    
    RUN mkdir -p "$UPLOAD_PATH"
    COPY "$PHP_APP_ZIP" "$UPLOAD_PATH/"
    RUN unzip "$UPLOAD_PATH/$PHP_APP_ZIP" -d "$WEB_ROOT/"
    
    ENTRYPOINT ["/usr/local/bin/init.sh"]
    Jaggery
    Code Block
    FROM docker.cloud.wso2.com/wso2-cloud/jaggery:0.11.0-alpine3.4-oracle-jdk1.8.0
     
    ENV CARBON_HOME_DIR="/home/wso2user/wso2as-5.3.0"
    ENV JAGGERY_APP_ZIP  <APP_ARTIFACT_NAME>
    ENV JAGGERY_APP_HOME $CARBON_HOME_DIR/repository/deployment/server/jaggeryapps/
    ENV APP_HOST 127.0.0.1
    ENV TOTAL_MEMORY 512
    
    COPY "$JAGGERY_APP_ZIP" "$JAGGERY_APP_HOME"
    WORKDIR "$JAGGERY_APP_HOME"
    RUN mv "$JAGGERY_APP_ZIP" ${JAGGERY_APP_ZIP%.upload}.zip && \
        sed -i '/<!--HostName>/c\\t<HostName>'$APP_HOST'</HostName>' $CARBON_HOME_DIR/repository/conf/carbon.xml && \
        sed -i '/<!--MgtHostName>/c\\t<MgtHostName>'$APP_HOST'</MgtHostName>' $CARBON_HOME_DIR/repository/conf/carbon.xml
    WORKDIR "/"
    CMD ["bash", "-c", "source /init.sh"]
    WSO2 Data Service
    Code Block
    FROM docker.cloud.wso2.com/wso2-cloud/wso2dss:3.5.1-alpine3.4-oracle-jdk1.8.0
    
    ENV CARBON_HOME_PATH /home/wso2user/wso2dss-3.5.1
    ENV DATASERVICE_DBS <APP_ARTIFACT_NAME>
    ENV CAR_DEPLOYMENT_DIR $CARBON_HOME_PATH/repository/deployment/server/carbonapps/
    ENV APP_HOST 127.0.0.1
    
    ENV TOTAL_MEMORY 512
    
    RUN mkdir -p $CAR_DEPLOYMENT_DIR
    
    COPY "$DATASERVICE_DBS" "$CAR_DEPLOYMENT_DIR"
    RUN sed -i '/<!--HostName>/c\\t<HostName>'$APP_HOST'</HostName>' $CARBON_HOME_PATH/repository/conf/carbon.xml && \
        sed -i '/<!--MgtHostName>/c\\t<MgtHostName>'$APP_HOST'</MgtHostName>' $CARBON_HOME_PATH/repository/conf/carbon.xml
    WORKDIR "/"
    CMD ["bash", "-c", "source /init.sh"]
  7. In the above code, replace <APP_ARTIFACT_NAME>  with the actual artifact name (e.g.,  foo-app.war) and copy the artifact to the folder you created in step 4 (e.g., /home/user/dev/foo-app/).

  8. Note that you now have the following folder structure in the folder that you created in step 4.

    Code Block
    dev/foo-app/
       ├── Dockerfile
       └── foo-app.war
  9. Log in to docker.cloud.wso2.com using your WSO2 user account and run the following command to pull the docker image that you want to use. The Docker image should change according to your application type.

    Code Block
    docker login docker.cloud.wso2.com
    Username: your_username@wso2.com
    Password: ******
    Login Succeeded
    
    docker pull <Docker image you selected in step 2>
    Example: docker pull docker.cloud.wso2.com/wso2-cloud/tomcat:8.5.5-ubuntu16.04-oracle-jdk1.8.0
  10. Run the Docker build command to create an image as follows:

    Code Block
    docker build -t <app-name:version> -f Dockerfile.
    Example: docker build -t foo-app:1.0.0 -f Dockerfile .
  11. Start a container with your application. To see the commands that correspond to your app type, expand the link below.

    Expand
    titleExpand to see the command to start a container for your app type...
    App TypeCommand
    WSO2 ESB Composite Application
    Code Block
    docker run -p 127.0.0.1:80:8280 -p 127.0.0.1:443:8243 -it <app-name:version>
    Example: docker run -p 127.0.0.1:80:8280 -p 127.0.0.1:443:8243 -it foo-app:1.0.0
    Ballerina Service<Coming up soon>
    Java Web Application
    Code Block
    docker run -p 127.0.0.1:80:8080 -p 127.0.0.1:443:8443 -it <app-name:version>
    Example: docker run -p 127.0.0.1:80:8080 -p 127.0.0.1:443:8443 -it foo-app:1.0.0
    Java Microservice 2.0.0
    Code Block
    docker run -p 127.0.0.1:80:8080 -p 127.0.0.1:443:8443 -it <microservice-sample>
    PHP
    Code Block
    docker run -p 127.0.0.1:80:80 -p 127.0.0.1:443:443 <php-sample>
    Jaggery
    Code Block
    docker run -p 127.0.0.1:80:9763 -p 127.0.0.1:443:9443 -it <jaggery-sample>
    Data Service
    Code Block
    docker run -p 127.0.0.1:80:9763 -p 127.0.0.1:443:9443 -it <dataservice-sample>
  12. Using a web browser, access your application's URL to test it.

...