Skip to content

Commit 4fcae9b

Browse files
author
Nisha K
committed
Use the default driver in Dockerfile
This is work towards tern-tools#1082 We use the default driver so we can run Tern in an unprivileged container. Hence we don't need the --driver option in the Dockerfiles, and the --privileged option in the docker_run.sh script. Signed-off-by: Nisha K <[email protected]>
1 parent 6c0d1e9 commit 4fcae9b

File tree

4 files changed

+31
-38
lines changed

4 files changed

+31
-38
lines changed

ci/Dockerfile

+24-31
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,32 @@
1-
# Copyright (c) 2019-2020 VMware, Inc. All Rights Reserved.
1+
# Copyright (c) 2019-2021 VMware, Inc. All Rights Reserved.
22
# SPDX-License-Identifier: BSD-2-Clause
33

4-
FROM debian:buster
4+
FROM python:3.9-slim-buster as base
55

6-
# Install fuse-overlayfs and Tern dependencies
7-
RUN apt-get update && \
8-
apt-get -y install \
6+
FROM base as builder
7+
8+
RUN mkdir /install
9+
WORKDIR /install
10+
11+
COPY dist/tern-*.tar.gz .
12+
RUN pip install --no-warn-script-location --prefix=/install \
13+
tern-*.tar.gz
14+
15+
FROM base
16+
17+
RUN echo "deb http://deb.debian.org/debian bullseye main" > /etc/apt/sources.list.d/bullseye.list \
18+
&& echo "Package: *\nPin: release n=bullseye\nPin-Priority: 50" > /etc/apt/preferences.d/bullseye \
19+
&& apt-get update \
20+
&& apt-get install -y --no-install-recommends \
921
attr \
1022
findutils \
23+
fuse-overlayfs/bullseye \
24+
fuse3/bullseye \
1125
git \
12-
gnupg2 \
1326
jq \
14-
python3 \
15-
python3-pip \
16-
python3-setuptools \
17-
tar \
18-
util-linux \
19-
wget && \
20-
echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_10/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list && \
21-
wget --no-verbose https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_10/Release.key -O - | apt-key add - && \
22-
apt-get update && \
23-
apt-get -y install \
24-
buildah \
25-
fuse-overlayfs && \
26-
apt-get clean && \
27-
rm -rf /var/lib/apt/lists/*
28-
29-
# Adjust storage.conf to enable Fuse storage.
30-
RUN sed -i -e 's|^#mount_program|mount_program|g' -e '/additionalimage.*/a "/var/lib/shared",' /etc/containers/storage.conf
31-
32-
# Install tern with latest changes
33-
COPY dist/tern-*.tar.gz .
34-
RUN pip3 install --upgrade pip && \
35-
pip3 install --no-cache-dir \
36-
tern-*.tar.gz
27+
&& rm -rf /var/lib/apt/lists/*
28+
29+
COPY --from=builder /install /usr/local
3730

38-
ENTRYPOINT ["tern", "--driver", "fuse"]
39-
CMD ["-h"]
31+
ENTRYPOINT ["tern"]
32+
CMD ["--help"]

docker/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020 VMware, Inc. All Rights Reserved.
1+
# Copyright (c) 2019-2021 VMware, Inc. All Rights Reserved.
22
# SPDX-License-Identifier: BSD-2-Clause
33

44
FROM python:3.9-slim-buster as base
@@ -27,5 +27,5 @@ RUN echo "deb http://deb.debian.org/debian bullseye main" > /etc/apt/sources.lis
2727

2828
COPY --from=builder /install /usr/local
2929

30-
ENTRYPOINT ["tern", "--driver", "fuse"]
31-
CMD ["--help"]
30+
ENTRYPOINT ["tern"]
31+
CMD ["--help"]

docker/Dockerfile.scancode

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020 VMware, Inc. All Rights Reserved.
1+
# Copyright (c) 2019-2021 VMware, Inc. All Rights Reserved.
22
# SPDX-License-Identifier: BSD-2-Clause
33

44
FROM python:3.9-slim-buster as base
@@ -34,5 +34,5 @@ RUN echo "deb http://deb.debian.org/debian bullseye main" > /etc/apt/sources.lis
3434

3535
COPY --from=builder /install /usr/local
3636

37-
ENTRYPOINT ["tern", "--driver", "fuse"]
37+
ENTRYPOINT ["tern"]
3838
CMD ["--help"]

docker_run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#
3-
# Copyright (c) 2019-2020 VMware, Inc. All Rights Reserved.
3+
# Copyright (c) 2019-2021 VMware, Inc. All Rights Reserved.
44
# SPDX-License-Identifier: BSD-2-Clause
55
#
66
# Script to run Tern within a prebuilt Docker container
@@ -11,4 +11,4 @@
1111
# Usage: ./docker_run.sh <tern image> <tern command arguments in quotes> > output.txt
1212
# Example: ./docker_run.sh ternd "report -i golang:alpine" > output.txt
1313

14-
docker run --privileged --device /dev/fuse -v /var/run/docker.sock:/var/run/docker.sock --rm $1 $2
14+
docker run -v /var/run/docker.sock:/var/run/docker.sock --rm $1 $2

0 commit comments

Comments
 (0)