Skip to content

Commit

Permalink
updated to Java OpenJDK 11
Browse files Browse the repository at this point in the history
  • Loading branch information
openkbs committed Jul 20, 2020
1 parent 3f85a72 commit eabc7d4
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 401 deletions.
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#FROM ${BASE_IMAGE:-ubuntu:20.04}
FROM ${BASE_IMAGE:-ubuntu:18.04}

MAINTAINER DrSnowbird "DrSnowbird@openkbs.org"
Expand All @@ -10,9 +11,9 @@ ENV DEBIAN_FRONTEND noninteractive
ENV USER_ID=${USER_ID:-1000}
ENV GROUP_ID=${GROUP_ID:-1000}

#ENV JAVA_VERSION=8
#ENV JAVA_VERSION=11
#ENV JAVA_VERSION=14
#ARG JAVA_VERSION=8
ARG JAVA_VERSION=11
#ARG JAVA_VERSION=14
ENV JAVA_VERSION=${JAVA_VERSION:-8}

##############################################
Expand Down Expand Up @@ -216,6 +217,11 @@ RUN ln -s ${INSTALL_DIR}/scripts/docker-entrypoint.sh /docker-entrypoint.sh
#############################################
RUN chown ${USER}:${USER} -R ${INSTALL_DIR}/scripts /docker-entrypoint.sh

#############################################################################
#### ---- Fix sudo: setrlimit(RLIMIT_CORE): Operation not permitted ---- ####
#############################################################################
RUN echo "Set disable_coredump false" | sudo tee -a /etc/sudo.conf

############################################
#### ---- Set up user environments ---- ####
############################################
Expand Down
113 changes: 78 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,70 +1,113 @@
SHELL := /bin/bash

VERSION := 1.0.0
# -------------------------------------------------------------------------------------------------------
# login first (Registry: e.g., hub.docker.io, registry.localhost:5000, etc.)
# a.) docker login
# or
# b.) sudo docker login -p FpXM6Qy9vVL5kPeoefzxwA-oaYb-Wpej2iXTwV7UHYs -e unused -u unused docker-registry-default.openkbs.org
# e.g. (using Openshift)
# oc process -f ./files/deployments/template.yml -v API_NAME=$(REGISTRY_IMAGE) > template.active
#
# to run:
# make <verb> [ APP_VERSION=<...> DOCKER_NAME=<...> REGISTRY_HOST=<...> ]
# example:
# make build
# make up
# make down
# -------------------------------------------------------------------------------------------------------

DOCKER_REPO := openkbs
SHELL := /bin/bash

## == Default is Ubuntu:20.04 as Docker base image ==
BASE_IMAGE := $(BASE_IMAGE)

## -- To Check syntax:
# cat -e -t -v Makefile

# The name of the executable (default is current directory name)
# DOCKER := json-server-docker
DOCKER := $(shell echo $${PWD\#\#*/})
# The name of the container (default is current directory name)
#DOCKER_NAME := $(shell echo $${PWD\#\#*/})
DOCKER_NAME := $(shell echo $${PWD\#\#*/}|tr '[:upper:]' '[:lower:]'|tr "/: " "_" )

ORGANIZATION=$(shell echo $${ORGANIZATION:-openkbs})
APP_VERSION=$(shell echo $${APP_VERSION:-latest})
imageTag=$(ORGANIZATION)/$(DOCKER_NAME)

## Docker Registry (Private Server)
REGISTRY_HOST=
#REGISTRY_HOST=$(shell echo $${REGISTRY_HOST:-localhost:5000})
REGISTRY_IMAGE=$(REGISTRY_HOST)/$(ORGANIZATION)/$(DOCKER_NAME)

#VERSION?="$(APP_VERSION)-$$(date +%Y%m%d)"
VERSION?="$(APP_VERSION)"

NAME := $(DOCKER)
## -- Uncomment this to use local Registry Host --
DOCKER_IMAGE := $(ORGANIZATION)/$(DOCKER_NAME)

## -- To Check syntax:
# cat -e -t -v Makefile

# -- example --
#VOLUME_MAP := "-v $${PWD}/json:/project-json -v $${PWD}/data:/data"
#VOLUME_MAP := "-v $${PWD}/data:/home/developer/data -v $${PWD}/workspace:/home/developer/workspace"
VOLUME_MAP :=

# -- Local SAVE of image --
IMAGE_EXPORT_PATH := "$${PWD}/archive"

# { no, on-failure, unless-stopped, always }
RESTART_OPTION := no
RESTART_OPTION := always

SHA := $(shell git describe --match=NeVeRmAtCh --always --abbrev=40 --dirty=*)

.PHONY : clean
.PHONY: clean rmi build push pull up down run stop exec

clean :
echo $(NAME) $(DOCKER_REPO)/$(DOCKER):$(VERSION)
clean:
echo $(DOCKER_NAME) $(DOCKER_IMAGE):$(VERSION)

default: docker_build
default: build

docker_build:
@docker build \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` .
build:
docker build \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg CIRCLE_SHA1="$(SHA)" \
--build-arg version=$(VERSION) \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
-t $(DOCKER_REPO)/$(DOCKER):$(VERSION) .
sudo docker build \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg CIRCLE_SHA1="$(SHA)" \
--build-arg version=$(VERSION) \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
-t $(DOCKER_IMAGE):$(VERSION) .

push: build
docker push $(DOCKER_REPO)/$(DOCKER):$(VERSION)

sudo docker commit -m "$comment" ${containerID} ${imageTag}:$(VERSION)
sudo docker push $(DOCKER_IMAGE):$(VERSION)

docker tag $(imageTag):$(VERSION) $(REGISTRY_IMAGE):$(VERSION)
#sudo docker tag $(imageTag):latest $(REGISTRY_IMAGE):latest
docker push $(REGISTRY_IMAGE):$(VERSION)
#sudo docker push $(REGISTRY_IMAGE):latest
@if [ ! "$(IMAGE_EXPORT_PATH)" = "" ]; then \
mkdir -p $(IMAGE_EXPORT_PATH); \
sudo docker save $(REGISTRY_IMAGE):$(VERSION) | gzip > $(IMAGE_EXPORT_PATH)/$(DOCKER_NAME)_$(VERSION).tar.gz; \
fi
pull:
docker pull $(DOCKER_REPO)/$(DOCKER):$(VERSION)
@if [ "$(REGISTRY_HOST)" = "" ]; then \
sudo docker pull $(DOCKER_IMAGE):$(VERSION) ; \
else \
sudo docker pull $(REGISTRY_IMAGE):$(VERSION) ; \
fi


up: build
docker-compose up -d
sudo docker-compose up -d

down:
docker-compose down
sudo docker-compose down

run:
docker run --name=$(NAME) --restart=$(RESTART_OPTION) $(VOLUME_MAP) $(DOCKER_REPO)/$(DOCKER):$(VERSION)
sudo docker run --name=$(DOCKER_NAME) --restart=$(RESTART_OPTION) $(VOLUME_MAP) $(DOCKER_IMAGE):$(VERSION)

stop: run
docker stop --name=$(NAME)
sudo docker stop --name=$(DOCKER_NAME)

status:
sudo docker ps

rmi:
docker rmi $$(docker images -f dangling=true -q)
sudo docker rmi $$(docker images -f dangling=true -q)

exec: up
docker-compose exec $(DOCKER) /bin/bash
sudo docker-compose exec $(DOCKER_NAME) /bin/bash
Loading

0 comments on commit eabc7d4

Please sign in to comment.