-
Notifications
You must be signed in to change notification settings - Fork 51
/
Dockerfile
47 lines (37 loc) · 1.33 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -- Build time image --
FROM maven:3-eclipse-temurin-17 AS build
LABEL maintainer="[email protected]"
ARG LOCATION=/usr/local/a
# Copy all required source code into the image
RUN mkdir --parents ${LOCATION}/
COPY pom.xml ${LOCATION}/
COPY LICENSE ${LOCATION}/
COPY README.md ${LOCATION}/
COPY src ${LOCATION}/src
# The default hostname is 'localhost'
# But in a docker container that is still inside the container only
# We need to replace 'localhost' with 'host.docker.internal'
# and otherwise, user still needs to specify the alternative
RUN sed --in-place \
-e 's/localhost:/host.docker.internal:/' \
${LOCATION}/src/main/java/co/nordlander/a/A.java
# Build the A software in the usual way
RUN cd /usr/local/a && mvn package -DskipTests
# -- Runtime Image --
FROM eclipse-temurin:17
COPY --from=build /usr/local/a/target/*-jar-with-dependencies.jar /a/a.jar
# Create a new command that is always in the PATH
RUN echo "#!/bin/sh" > /usr/bin/a && \
echo "java \
-Dnashorn.args=--no-deprecation-warning \
-cp /a/a.jar \
co.nordlander.a.A \"\$@\"" >> /usr/bin/a && \
chmod a+rx /usr/bin/a
RUN cat /usr/bin/a
# This will only show the usage
CMD a
# a more useful use is:
# docker run a a --get queue1
# note that 'a' has to be specified twice
# the first one is the image name
# the second one is the 'alternative' commands that we want to run