From 0ce916c3a84a4aa6fb55f64a628bdd7fa476f471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sat, 20 Mar 2021 11:20:06 +0000 Subject: [PATCH] :whale: Lightweight dockerfiles (#53) --- docker-images/README.md | 5 +++++ docker-images/jdk11-mvn3.6.3.Dockerfile | 17 +++++++++++++++ docker-images/jdk11.Dockerfile | 15 +++++++++++++ docker-images/python3.Dockerfile | 11 ++++++++++ docker-images/release-example.sh | 29 +++++++++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 docker-images/README.md create mode 100644 docker-images/jdk11-mvn3.6.3.Dockerfile create mode 100644 docker-images/jdk11.Dockerfile create mode 100644 docker-images/python3.Dockerfile create mode 100755 docker-images/release-example.sh diff --git a/docker-images/README.md b/docker-images/README.md new file mode 100644 index 0000000..0a72b8f --- /dev/null +++ b/docker-images/README.md @@ -0,0 +1,5 @@ +## Docker images + +Here you find useful and lightweight Dockerfiles. + +Furthermore, there is also a `release-example.sh` file that will guide you through on how to release your Docker image to any desired registry. diff --git a/docker-images/jdk11-mvn3.6.3.Dockerfile b/docker-images/jdk11-mvn3.6.3.Dockerfile new file mode 100644 index 0000000..d03955c --- /dev/null +++ b/docker-images/jdk11-mvn3.6.3.Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:3.11 + +ENV JAVA_VERSION="11.0.5_p10-r0" +ENV MAVEN_VERSION="3.6.3-r0" + +ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk +ENV PATH $PATH:/usr/lib/jvm/java-11-openjdk/jre/bin:/usr/lib/jvm/java-11-openjdk/bin + +RUN set -x \ + && apk update \ + && apk add --no-cache \ + openjdk11="${JAVA_VERSION}" \ + maven \ + && rm -rf /var/cache/* \ + && rm -rf /root/.cache/* + +CMD ["/bin/sh"] diff --git a/docker-images/jdk11.Dockerfile b/docker-images/jdk11.Dockerfile new file mode 100644 index 0000000..087f476 --- /dev/null +++ b/docker-images/jdk11.Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.11 + +ENV JAVA_VERSION="11.0.5_p10-r0" + +ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk +ENV PATH $PATH:/usr/lib/jvm/java-11-openjdk/jre/bin:/usr/lib/jvm/java-11-openjdk/bin + +RUN set -x \ + && apk update \ + && apk add --no-cache \ + openjdk11="${JAVA_VERSION}" \ + && rm -rf /var/cache/* \ + && rm -rf /root/.cache/* + +CMD ["/bin/sh"] diff --git a/docker-images/python3.Dockerfile b/docker-images/python3.Dockerfile new file mode 100644 index 0000000..2cf6386 --- /dev/null +++ b/docker-images/python3.Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.11 + +RUN set -x \ + && apk update \ + && apk add --no-cache \ + python3 \ + && pip3 install --no-cache-dir --upgrade pip \ + && rm -rf /var/cache/* \ + && rm -rf /root/.cache/* + +CMD ["/bin/sh"] diff --git a/docker-images/release-example.sh b/docker-images/release-example.sh new file mode 100755 index 0000000..28bc131 --- /dev/null +++ b/docker-images/release-example.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -eo pipefail + +DOCKERFILE=jdk11.Dockerfile +DOCKER_REGISTRY=docker.io +DOCKER_IMAGE=${DOCKER_REGISTRY}// +DOCKER_TAG=1.0.0 + +## LOGIN +echo 'Logging into docker hub' +echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + +## BUILD IMAGE +echo 'Building docker image' +docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} -f ${DOCKERFILE} . + +## TAG IMAGE +echo 'Tagging image' +docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest + +## UPLOAD IMAGE +echo 'Uploading image' +docker push ${DOCKER_IMAGE}:${DOCKER_TAG} +docker push ${DOCKER_IMAGE}:latest + +## CLEAR WORKSPACE +echo 'Clearing workspace' +docker rmi ${DOCKER_IMAGE}:${DOCKER_TAG} +docker rmi ${DOCKER_IMAGE}:latest