NoIssue: Support for building runable docker container
This commit is contained in:
39
src/main/docker/Dockerfile_template
Normal file
39
src/main/docker/Dockerfile_template
Normal file
@@ -0,0 +1,39 @@
|
||||
FROM dockerreg.r35157.com/r35157/jre:24.0.1-2_amd64
|
||||
|
||||
LABEL maintainer="Minimons <minimons@r35157.com>"
|
||||
|
||||
# Setup environment
|
||||
ENV NENJIMHUB_HOME=/usr/local/software/nenjimhub
|
||||
WORKDIR /usr/local/software
|
||||
USER root
|
||||
RUN mkdir nenjimhub-_VERSION_
|
||||
RUN ln -s nenjimhub-_VERSION_ nenjimhub
|
||||
WORKDIR nenjimhub
|
||||
RUN mkdir libs
|
||||
|
||||
# These dirs are expected to be overshadowed by host mounts
|
||||
RUN mkdir conf logs in out archive
|
||||
|
||||
# Install basic tools
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y procps
|
||||
|
||||
# Set timezone
|
||||
ENV TZ=Europe/Copenhagen
|
||||
RUN apt-get install -y tzdata \
|
||||
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||
&& echo $TZ > /etc/timezone \
|
||||
&& dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
# Clean-up
|
||||
RUN apt-get autoremove \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install application and configuration (Do this as late as possible to be able to reuse layers between builds)
|
||||
COPY start.sh .
|
||||
COPY conf/* conf
|
||||
COPY libs/*.jar libs
|
||||
|
||||
CMD ["./start.sh"]
|
||||
|
||||
18
src/main/docker/publish_template
Normal file
18
src/main/docker/publish_template
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
NAME=nenjimhub
|
||||
VERSION=_VERSION__amd64
|
||||
|
||||
VTAG=dockerreg.r35157.com/r35157/${NAME}:${VERSION}
|
||||
LTAG=dockerreg.r35157.com/r35157/${NAME}:latest
|
||||
|
||||
docker tag r35157/${NAME}:${VERSION} ${VTAG}
|
||||
docker tag r35157/${NAME}:${VERSION} ${LTAG}
|
||||
|
||||
echo "Publishing of '${VTAG}' and '${LTAG}'..."
|
||||
docker push ${VTAG}
|
||||
docker push ${LTAG}
|
||||
|
||||
echo "Publishing completed!"
|
||||
22
src/main/docker/stack.yml
Normal file
22
src/main/docker/stack.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
nenjimhub:
|
||||
hostname: nenjimhub
|
||||
image: dockerreg.r35157.com/r35157/nenjimhub:latest
|
||||
deploy:
|
||||
replicas: 1
|
||||
resources:
|
||||
limits:
|
||||
memory: 128m
|
||||
restart_policy:
|
||||
condition: any
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
window: 120s
|
||||
volumes:
|
||||
- /home/op/nenjimhub/conf:/usr/local/software/nenjimhub/conf
|
||||
- /home/op/nenjimhub/logs:/usr/local/software/nenjimhub/logs
|
||||
- /home/op/nenjimhub/in:/usr/local/software/nenjimhub/in
|
||||
- /home/op/nenjimhub/out:/usr/local/software/nenjimhub/out
|
||||
- /home/op/nenjimhub/archive:/usr/local/software/nenjimhub/archive
|
||||
6
src/main/docker/start.sh
Executable file
6
src/main/docker/start.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CLASSPATH=$(echo libs/*.jar | tr ' ' ':')
|
||||
|
||||
java -Dlog4j.configurationFile=conf/log4j2.xml -cp "$CLASSPATH" com.r35157.nenjim.hubd.impl.ref.Main
|
||||
sleep 100000
|
||||
3
src/main/docker/up_stack
Executable file
3
src/main/docker/up_stack
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker stack deploy --compose-file /home/op/stack.yml stack --detach=true
|
||||
18
src/main/java/com/r35157/nenjim/hubd/impl/ref/Main.java
Normal file
18
src/main/java/com/r35157/nenjim/hubd/impl/ref/Main.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.r35157.nenjim.hubd.impl.ref;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new Main();
|
||||
}
|
||||
|
||||
public Main() throws Exception {
|
||||
log.info("Initializing NenjimHub...");
|
||||
log.info("Ready!");
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private static final Logger log = LogManager.getLogger(Main.class);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.r35157.nenjim.hubd.impl.ref;
|
||||
|
||||
import com.r35157.nenjim.hubd.SomeInterface;
|
||||
|
||||
public class SomeImpl implements SomeInterface {
|
||||
public String concat(String x, String y) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
public void divideByZero() throws ArithmeticException {
|
||||
int a = 0/0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user