Skip to content

Commit 8d1298c

Browse files
committed
docker: massive changes.
Addressed to #534
1 parent bab94be commit 8d1298c

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

docker/Dockerfile

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,50 @@
33
# https://github.com/docker-library/buildpack-deps/blob/a0a59c61102e8b079d568db69368fb89421f75f2/jessie/curl/Dockerfile
44
# https://github.com/docker-library/openjdk/blob/445f8b8d18d7c61e2ae7fda76d8883b5d51ae0a5/8-jre/Dockerfile
55
FROM openjdk:8u121-jre
6+
7+
# Informs Docker that the container listens on the specified network ports at runtime.
8+
# See also: https://docs.docker.com/engine/reference/builder/#expose
69
EXPOSE 8080
7-
COPY mystamps.war /tmp
8-
CMD [ "java", "-Dserver.address=0.0.0.0", "-jar", "/tmp/mystamps.war" ]
10+
11+
# Sets active Spring profile. Possible values are: test, prod and travis.
12+
# See also: https://docs.docker.com/engine/reference/builder/#env
13+
ENV SPRING_PROFILES_ACTIVE=test
14+
15+
# Creates base directories and unprivileged user.
16+
# See also: https://docs.docker.com/engine/reference/builder/#run
17+
RUN mkdir /data \
18+
&& useradd mystamps --home-dir /data/mystamps --create-home --comment 'MyStamps' \
19+
&& mkdir /data/uploads /data/heap-dumps \
20+
&& chown mystamps:mystamps /data/uploads /data/heap-dumps
21+
22+
# Creates mount points and marks them as holding externally mounted volumes from native host.
23+
# See also: https://docs.docker.com/engine/reference/builder/#volume
24+
VOLUME /data/uploads /data/heap-dumps
25+
26+
# Sets the user name to use when running the image and for any subsequent RUN, CMD and ENTRYPOINT instructions.
27+
# See also: https://docs.docker.com/engine/reference/builder/#user
28+
USER mystamps
29+
30+
# Sets the working directory for any subsequent RUN, CMD, ENTRYPOINT, COPY and ADD instructions.
31+
# See also: https://docs.docker.com/engine/reference/builder/#workdir
32+
WORKDIR /data/mystamps
33+
34+
# Copies mystamps.war into destination directory. File is created with a UID and GID of 0.
35+
# See also: https://docs.docker.com/engine/reference/builder/#copy
36+
COPY mystamps.war /data/mystamps
37+
38+
# Sets the command to be executed during container startup.
39+
# See also: https://docs.docker.com/engine/reference/builder/#cmd
40+
CMD [ "java" \
41+
, "-XX:+HeapDumpOnOutOfMemoryError" \
42+
, "-XX:HeapDumpPath=/data/heap-dumps" \
43+
, "-XX:+UseCompressedOops" \
44+
, "-Dsun.rmi.dgc.client.gcInterval=86400000" \
45+
, "-Dsun.rmi.dgc.server.gcInterval=86400000" \
46+
, "-Djava.security.egd=file:/dev/./urandom" \
47+
, "-Xmx128m" \
48+
, "-Xss256k" \
49+
, "-Dserver.address=0.0.0.0" \
50+
, "-jar" \
51+
, "mystamps.war" \
52+
]

docker/Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
build-image:
1+
build:
22
ln -v ../target/mystamps.war mystamps.war && \
33
docker build --tag mystamps:0.3.0 .; \
44
rm -fv mystamps.war
55

6-
.PHONY: build-image
6+
start:
7+
docker run --name mystamps --publish 8080:8080 --detach mystamps:0.3.0
8+
9+
stop:
10+
docker stop mystamps
11+
12+
remove:
13+
docker rm mystamps
14+
15+
remove-completely:
16+
docker rm -v mystamps
17+
18+
.PHONY: build start stop remove remove-completely

0 commit comments

Comments
 (0)