Skip to content

Commit b9dfe46

Browse files
Improved Dockerfile by adding multi-stage build and increasing image size to allow faster restart.
1 parent 8f136af commit b9dfe46

5 files changed

Lines changed: 38 additions & 43 deletions

File tree

Dockerfile

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
# syntax=docker/dockerfile:1
2+
FROM alpine:3.14
3+
4+
# Prepare the environment
5+
RUN apk add maven git
6+
7+
# Build the jar files
8+
WORKDIR /home/user
9+
COPY local-maven-repo ./local-maven-repo
10+
COPY src ./src
11+
COPY pom.xml .
12+
RUN mvn package || exit
13+
14+
RUN git clone --progress https://git.busybox.net/busybox/
15+
RUN git clone --progress https://github.com/torvalds/linux.git
16+
217
FROM ubuntu:20.04
318

419
# Create a user
5-
ARG USER_ID
6-
ARG GROUP_ID
7-
RUN addgroup --gid $GROUP_ID user
8-
RUN adduser --disabled-password --home /home/user --gecos '' --uid $USER_ID --ingroup user user
20+
RUN adduser --disabled-password --home /home/user --gecos '' user
921

1022
# Prepare the environment
1123
RUN apt-get update \
1224
&& apt-get install -y --no-install-recommends tzdata
1325
RUN apt-get install -y --no-install-recommends build-essential libelf-dev libssl-dev flex bison libselinux1-dev git
1426

15-
1627
# Setup working directory
1728
WORKDIR /resources
1829
COPY ./docker-resources/ubuntu-repos.txt .
@@ -26,17 +37,33 @@ RUN apt-get update \
2637
&& apt-get install -y --no-install-recommends gcc-4.4
2738
RUN ln -s /bin/gcc-4.4 /bin/gcc
2839
RUN rm -rf VariabilityExtraction
29-
RUN ls -al
3040
RUN gcc --version
3141
RUN java -version
32-
RUN apt-get install -y --no-install-recommends maven bc
42+
RUN apt-get install -y --no-install-recommends bc
3343

44+
45+
WORKDIR /home/user
46+
# Copy JAR from previous stage
47+
COPY --from=0 /home/user/target /home/user/target
48+
RUN cp target/VariabilityExtraction-*-jar-with* .
49+
50+
# Copy required scripts and properties
3451
COPY docker-resources/extract.sh /home/user/
52+
COPY docker-resources/entrypoint.sh /home/user/
53+
COPY docker-resources/fix-perms.sh /home/user/
54+
COPY docker-resources/KernelHaven.jar /home/user/
3555
COPY docker-resources/variability_analysis_BusyBox.properties /home/user/
3656
COPY docker-resources/variability_analysis_Linux.properties /home/user/
57+
3758
RUN mkdir -p /home/user/extraction-results/output
3859
RUN chown user:user /home/user -R
39-
WORKDIR /home/user
60+
RUN chmod +x entrypoint.sh
61+
RUN chmod +x fix-perms.sh
4062
RUN chmod +x extract.sh
4163

42-
ENTRYPOINT ["./extract.sh"]
64+
# Copy repositories from previous stage
65+
COPY --from=0 /home/user/linux /home/user/linux
66+
COPY --from=0 /home/user/busybox /home/user/busybox
67+
68+
ENTRYPOINT ["./entrypoint.sh", "./extract.sh"]
69+
USER user

docker-resources/extract.sh

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,12 @@ java -version
55

66
cd /home/user || exit
77
ls -l
8-
git clone --progress https://oauth2:[email protected]/mse/VariantSync/VariabilityExtraction.git
9-
cd VariabilityExtraction || exit
10-
git status
11-
echo "Listing files in VariabilityExtraction"
12-
ls -l
13-
echo ""
14-
15-
echo "Building with Maven"
16-
mvn package || exit
17-
echo ""
18-
19-
echo "Copying resources"
20-
cp target/VariabilityExtraction-*-jar-with* docker-resources/KernelHaven.jar ..
21-
cd ..
22-
echo ""
23-
24-
echo "Files in WORKDIR"
25-
ls .
26-
echo ""
278

289
echo "Files in extraction-results"
2910
ls -l extraction-results
3011

3112
if [ "$1" == 'busybox' ]
3213
then
33-
git clone --progress https://git.busybox.net/busybox/
3414
echo "Executing variability extraction of BusyBox."
3515
if [ $# == 1 ]
3616
then
@@ -44,8 +24,6 @@ then
4424
fi
4525
elif [ "$1" == 'linux' ]
4626
then
47-
echo "Cloning Linux, this will take quite some time."
48-
git clone --progress https://github.com/torvalds/linux.git
4927
echo "Executing variability extraction of Linux."
5028
if [ $# == 1 ]
5129
then

docker-resources/maven-setup.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

docker-resources/variability_analysis_Linux.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extraction.timeout = 600
2727
### Analysis Parameters ###
2828
# How many commits should be analyzed in parallel? Warning: each task requires a considerable amount
2929
# of resources
30-
analysis.number_of_tasks = 3
30+
analysis.number_of_tasks = 1
3131

3232
# The folders which are considered by KbuildMiner can be specified manually with the following property. Normally,
3333
# they are determined automatically, which we consider to be the best option in most cases

start-extraction.bat

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@echo "Starting extraction"
2+
if not exist "extraction-results" mkdir extraction-results
23

34
@if "%1"=="busybox" GOTO BUSYBOX
45
@if "%1"=="linux" GOTO LINUX
@@ -7,18 +8,12 @@
78
@GOTO AFTER
89

910
:BUSYBOX
10-
@if not exist "extraction-results" mkdir extraction-results
11-
@if not exist "extraction-results/busybox" mkdir extraction-results/busybox
12-
1311
@echo "Starting the extraction"
1412
@docker run --rm -v "%cd%/extraction-results/busybox":"/home/user/extraction-results/output" variability-extraction %*
1513

1614
@GOTO AFTER
1715

1816
:LINUX
19-
@if not exist "extraction-results" mkdir extraction-results
20-
@if not exist "extraction-results/linux" mkdir extraction-results/linux
21-
2217
@echo "Starting the extraction"
2318
@docker run --rm -v "%cd%/extraction-results/linux":"/home/user/extraction-results/output" variability-extraction %*
2419

0 commit comments

Comments
 (0)