Skip to content

Commit

Permalink
🐳 Lightweight dockerfiles (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sérgio Martins authored Mar 20, 2021
1 parent ed73680 commit 0ce916c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docker-images/README.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions docker-images/jdk11-mvn3.6.3.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions docker-images/jdk11.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 11 additions & 0 deletions docker-images/python3.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
29 changes: 29 additions & 0 deletions docker-images/release-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eo pipefail

DOCKERFILE=jdk11.Dockerfile
DOCKER_REGISTRY=docker.io
DOCKER_IMAGE=${DOCKER_REGISTRY}/<your-docker-hub-user-name>/<your-image-name>
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

0 comments on commit 0ce916c

Please sign in to comment.