awesome-compose/sparkjava
Atomist Bot ab98a9215b Pin Docker image maven:3.8.5-eclipse-temurin-17
--platform=$BUILDPLATFORM
->
maven:3.8.5-eclipse-temurin-17@sha256:a554849fd74b733acb76379bd7df0ea26635a48ab9b54ede1e94bbeaaf448cf6

 [atomist:generated]
 [atomist-skill:atomist/docker-base-image-policy]

Signed-off-by: Atomist Bot <bot@atomist.com>
2022-10-07 01:36:48 +00:00
..
.docker add configuration to use sparkjava sample with Docker Dev Environments feature (#261) 2022-07-12 12:22:52 +02:00
sparkjava Pin Docker image maven:3.8.5-eclipse-temurin-17 2022-10-07 01:36:48 +00:00
compose.yaml Adopt Compose v2 (#240) 2022-05-10 11:59:25 +02:00
README.md Add "Open in Docker Dev Environments" links (#280) 2022-09-01 11:39:33 -05:00

Compose sample application

Use with Docker Development Environments

You can open this sample in the Dev Environments feature of Docker Desktop version 4.12 or later.

Open in Docker Dev Environments Open in Docker Dev Environments

Spark Java

Project structure:

.
├── compose.yaml
├── README.md
└── sparkjava
    ├── Dockerfile
    └── ...

compose.yaml

services:
  sparkjava:
    build: sparkjava
    ports:
    - 8080:8080

The compose file defines an application with one service sparkjava. When deploying the application, docker compose maps port 8080 of the sparkjava service container to port 8080 of the host as specified in the file. Make sure port 8080 on the host is not already being in use.

Deploy with docker compose

$ docker compose up -d
Creating network "sparkjava_default" with the default driver
Building sparkjava
Step 1/11 : FROM maven:3.6.3-jdk-11 AS build
3.6.3-jdk-11: Pulling from library/maven
...
Successfully tagged sparkjava_sparkjava:latest
WARNING: Image for service sparkjava was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating sparkjava_sparkjava_1 ... done

Expected result

Listing containers must show one container running and the port mapping as below:

$ docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                  NAMES
5af94cb25394        sparkjava_sparkjava   "/bin/sh -c 'java -j…"   20 seconds ago      Up 19 seconds       0.0.0.0:8080->8080/tcp   sparkjava_sparkjava_1

After the application starts, navigate to http://localhost:8080 in your web browser or run:

$ curl localhost:8080
Hello from Docker!

Stop and remove the containers

$ docker compose down
Stopping sparkjava_sparkjava_1 ... done
Removing sparkjava_sparkjava_1 ... done
Removing network sparkjava_default