Merge pull request 'feature/docker' (#3) from feature/docker into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: java/labyrinth-server#3
This commit is contained in:
Manuel Friedli 2023-04-01 00:26:22 +02:00
commit 61d35794e6
4 changed files with 51 additions and 6 deletions

View file

@ -1,12 +1,19 @@
kind: pipeline
type: docker
name: default
steps:
- name: test
- name: build
image: maven:3.8-openjdk-18-slim
commands:
- mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
when:
branch:
include:
- master
- feature/*
- name: test
image: maven:3.8-openjdk-18-slim
commands:
- mvn test -B
when:
branch:
@ -25,4 +32,40 @@ steps:
- master
event:
exclude:
- pull_request
- pull_request
- name: build_docker_image
image: plugins/docker
settings:
registry: gittr.ch
username: manuel
password:
from_secret: docker-token
repo: gittr.ch/java/labyrinth
tags:
- latest
dockerfile: docker/Dockerfile
when:
branch:
- master
event:
exclude:
- pull_request
- tag
- name: build_docker_image_release
image: plugins/docker
settings:
registry: gittr.ch
username: manuel
password:
from_secret: docker-token
repo: gittr.ch/java/labyrinth
tags:
- latest
- ${DRONE_TAG}
dockerfile: docker/Dockerfile
when:
branch:
- master
event:
include:
- tag

View file

@ -1,4 +1,4 @@
FROM openjdk:11
FROM openjdk:17-slim
COPY target/labyrinth-server-*.jar /app/app.jar

View file

@ -18,6 +18,8 @@
<logback.version>1.4.6</logback.version>
<lombok.version>1.18.26</lombok.version>
<slf4j.version>2.0.5</slf4j.version>
<java.source.version>17</java.source.version>
<java.target.version>17</java.target.version>
</properties>
<dependencies>

View file

@ -105,15 +105,15 @@ public class LabyrinthServer {
exchange.sendResponseHeaders(302, -1);
return;
}
final Labyrinth labyrinth = new Labyrinth(width, height, id);
final byte[] render;
try {
final Labyrinth labyrinth = new Labyrinth(width, height, id);
render = output.render(labyrinth);
} catch (Exception e) {
responseHeaders.add("Content-type", "text/plain; charset=UTF-8");
exchange.sendResponseHeaders(500, 0);
final OutputStream responseBody = exchange.getResponseBody();
responseBody.write(("Error: " + e).getBytes(StandardCharsets.UTF_8));
responseBody.write(("Error: " + e.getMessage()).getBytes(StandardCharsets.UTF_8));
responseBody.flush();
return;
}