64 lines
1.3 KiB
Docker
64 lines
1.3 KiB
Docker
|
# Image to build the application
|
||
|
FROM ubuntu:bionic
|
||
|
|
||
|
RUN \
|
||
|
# Create builder user
|
||
|
groupadd builder && \
|
||
|
useradd builder -s /bin/bash -m -g builder -G sudo && \
|
||
|
echo 'builder:builder' |chpasswd && \
|
||
|
mkdir /home/builder/app && \
|
||
|
apt-get update && \
|
||
|
# Install utilities
|
||
|
apt-get install -y \
|
||
|
wget \
|
||
|
curl \
|
||
|
vim \
|
||
|
git \
|
||
|
zip \
|
||
|
bzip2 \
|
||
|
python \
|
||
|
build-essential \
|
||
|
software-properties-common \
|
||
|
sudo && \
|
||
|
# install OpenJDK 11
|
||
|
add-apt-repository ppa:openjdk-r/ppa && \
|
||
|
apt-get update && \
|
||
|
apt-get install -y openjdk-11-jdk && \
|
||
|
update-java-alternatives -s java-1.11.0-openjdk-amd64 && \
|
||
|
# Install Maven
|
||
|
apt-get install -y maven && \
|
||
|
# cleanup
|
||
|
apt-get clean && \
|
||
|
rm -rf \
|
||
|
/var/lib/apt/lists/* \
|
||
|
/tmp/* \
|
||
|
/var/tmp/*
|
||
|
|
||
|
RUN \
|
||
|
# fix builder user permissions
|
||
|
chown -R builder:builder \
|
||
|
/home/builder && \
|
||
|
# cleanup
|
||
|
rm -rf \
|
||
|
/home/builder/.cache/ \
|
||
|
/var/lib/apt/lists/* \
|
||
|
/tmp/* \
|
||
|
/var/tmp/*
|
||
|
|
||
|
USER builder
|
||
|
|
||
|
WORKDIR "/home/builder/app"
|
||
|
|
||
|
# Copy sources
|
||
|
COPY . /home/builder/app/
|
||
|
|
||
|
# Compile project
|
||
|
RUN mvn package
|
||
|
|
||
|
# Image to run the application
|
||
|
FROM openjdk:11.0.11-jre-slim
|
||
|
|
||
|
COPY --from=0 /home/builder/app/target/permutations.jar /app/permutations.jar
|
||
|
|
||
|
ENTRYPOINT ["java", "-jar", "/app/permutations.jar"]
|