Skip to content

Deploying to Jacob Docker

Pat Sabpisal edited this page Sep 20, 2016 · 2 revisions

Pre-prerequisites

  1. Have the following plugin in pom.xml
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.11</version>
    <configuration>
            <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
            <dockerDirectory>src/main/docker</dockerDirectory>
            <resources>
                    <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                    </resource>
            </resources>
    </configuration>
</plugin>
  1. Have the following in src/main/docker/Dockerfile
FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD reachrabbit-0.9.0.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  1. Set tons of parameters in application-production.properties correctly.

Prerequisites

  1. Have Docker installed locally
  2. Have Docker Cloud account
  3. Signin using docker login command. So you can pull images from Docker cloud.

Pushing

To deploy to jacob, you will need to:

  1. Build a docker image using production configuration.

    `SPRING_PROFILES_ACTIVE=production mvn package docker:build``

This creates a docker image name reachrabbit/reachrabbit

  1. Tag it, (think of tag as commit)

    docker tag reachrabbit/reachrabbit ssabpisa/reachrabbit:tagname

  2. Push image to docker cloud

    docker push ssabpisa/reachrabbit:tagname

Note the thing behind the colon (:tagname) can be anything as long as you are consistent. For example, a tag that makes sense maybe "RC1-October"

Deploying

  1. SSH to reachrabbit.com (ws-jacob-twilight) or by direct IP 54.254.142.108

  2. Pull the image

    sudo docker pull ssabpisa/reachrabbit:tagname

  3. Run it

    sudo docker run -d -p 8080:8080 ssabpisa/reachrabbit:tagname

The -p parameter says that expose port 8080 on the inside as 8080 on the outside. The -d parameter says that detach immediate and run in background.

For debugging purpose you can omit the -d option, and see the trace.

  1. Check that it's running sudo docker ps
Clone this wiki locally