Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodforGod committed May 3, 2018
0 parents commit eb4648a
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/example*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.iml
.idea
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM debian:sid-slim

###### DISCLAIMER ######
#
# You must accept the Oracle Binary Code License Agreement for Java SE to use this image.
#
# Link to License: http://www.oracle.com/technetwork/java/javase/terms/license/index.html
#
###### DISCLAIMER ######

# Set java enviroment
ENV LANG=C.UTF-8 \
JAVA_MAJOR_VERSION=10 \
JAVA_MINOR_VERSION=0 \
JAVA_UPDATE=1 \
JAVA_BUILD=10 \
JAVA_PATH=fb4372174a714e6b8c52526dc134031e \
JAVA_TYPE=serverjre

ENV JAVA_FULL_VERSION="${JAVA_MAJOR_VERSION}.${JAVA_MINOR_VERSION}.${JAVA_UPDATE}"

ENV JAVA_HOME="/opt/java/${JAVA_TYPE}-${JAVA_FULL_VERSION}" \
JAVA_TAR="${JAVA_TYPE}-${JAVA_FULL_VERSION}_linux-x64_bin.tar.gz"

# Download oracle jre -> extract it -> add app user & group -> cleanup
# You can use USER 'app' for you app
RUN cd /tmp \
&& apt-get update \
&& apt-get install -y wget \
&& mkdir -p /opt/java \
&& wget --header "Cookie: oraclelicense=accept-securebackup-cookie;" \
--progress=dot:mega --tries=10 "http://download.oracle.com/otn-pub/java/jdk/${JAVA_FULL_VERSION}+${JAVA_BUILD}/${JAVA_PATH}/${JAVA_TAR}" \
&& tar -xzf $JAVA_TAR -C /opt/java \
&& mv /opt/java/jdk-$JAVA_FULL_VERSION /opt/java/$JAVA_TYPE-$JAVA_FULL_VERSION \
&& ln -s $JAVA_HOME $JAVA_HOME/bin/* /usr/bin/ \
&& rm -rf $JAVA_HOME/*src.zip \
$JAVA_HOME/lib/*javafx* \
$JAVA_HOME/lib/*jfx* \
$JAVA_HOME/lib/*awt* \
$JAVA_HOME/lib/libfontmanager.so \
$JAVA_HOME/lib/fonts \
$JAVA_HOME/lib/oblique-fonts \
&& apt-get remove -y wget \
&& apt-get clean -y \
&& apt-get autoremove -y \
&& apt-get autoclean -y \
&& rm -rf /tmp/* \
&& rm -rf /var/cache/apt/archives/* \
&& useradd -ms /bin/bash app

# Add java to path
ENV PATH $PATH:$JAVA_HOME/bin
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 GoodforGod

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Docker Debian Oracle Server JRE 10
Docker Debian Slim image with cleaned Oracle Server JRE 10 Update 1 (239MB for stretch)

You must accept the [Oracle Binary Code License Agreement for Java SE](http://www.oracle.com/technetwork/java/javase/terms/license/index.html) to use this image.

## Image
Image contains cleaned [Oracle Server JRE 10.0.1](http://www.oracle.com/technetwork/java/javase/downloads/sjre10-downloads-4417025.html), you can read about JRE difference [here](https://stackoverflow.com/questions/33407297/difference-between-server-jre-and-client-jre).
JRE is provided without *desktop, sources* and other unnecessary stuff except JVM.
So image have all *JVM* parts to run *Java applications* in Docker containers.

Image contains only Java Runtime Environment, so you must have compiled Java application.

There are two base images:

#### Latest
Uses base image [Debian Sid Slim](https://hub.docker.com/_/debian/) (63.3MB)

Image size with Server JRE (254MB)

#### Stretch
Uses base image [Debian Stretch Slim](https://hub.docker.com/_/debian/) (55.3MB)

Image size with Server JRE (239MB)

## Usage
Image have docker *USER* named **app** so you can use it for your application.

Just add code below in your *Dockerfile* to use start your application as a user *app*
```
USER app
```

Check [example](https://github.com/GoodforGod/https://github.com/GoodforGod/docker-debian-jre10server-oracle/tree/master/example) folder for *Dockerfile* example of image usage.
8 changes: 8 additions & 0 deletions example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM goodforgod/debian-jre10server-oracle

COPY helloworld-1.0.0.jar /
VOLUME /tmp/logs

USER app

ENTRYPOINT ["java", "-jar", "/helloworld-1.0.0.jar"]
Binary file added example/helloworld-1.0.0.jar
Binary file not shown.
25 changes: 25 additions & 0 deletions example/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

DOCKERFILE=Dockerfile
CONT_NAME=helloworld
IMAGE_NAME=helloworld

CONT_ID=$(sudo docker ps -a -q --filter ancestor=$CONT_NAME)

if [ -z "$CONT_ID" ]
then
echo 'Container is not exist'

else
echo "[Removing] container with ID - $CONT_ID"

sudo docker stop $CONT_ID
sudo docker rm $CONT_ID
sudo docker rmi $IMAGE_NAME
fi

echo '[Redeploying]'

sudo docker build --tag=$IMAGE_NAME - < $DOCKERFILE
sudo docker run -d --name $CONT_NAME -p 8080:8080 $IMAGE_NAME
sudo docker ps

0 comments on commit eb4648a

Please sign in to comment.