Skip to content

Commit 3a0ac50

Browse files
author
Nisha K
committed
Modify environments to install skopeo
This is work towards tern-tools#948 Now that skopeo has become the de-facto tool to download container images, we will switch our instructions to install skopeo and use it in our build and development environments. At this time, skopeo is available on Ubuntu 20.04 through the Kubic project, hence there may need to be some additional changes in the future as the upstream package creators improve. Signed-off-by: Nisha K <[email protected]>
1 parent 0891287 commit 3a0ac50

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

Diff for: README.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Tern gives you a deeper understanding of your container's bill of materials so y
5656

5757
![Tern quick demo](/docs/img/tern_demo_fast.gif)
5858

59-
6059
# Getting Started<a name="getting-started"/>
6160

6261
## GitHub Action<a name="github-action"/>
@@ -70,13 +69,16 @@ If you have a Linux OS you will need a distro with a kernel version >= 4.0 (Ubun
7069
- Python 3.6 or newer (sudo apt-get install python3.6(3.7) or sudo dnf install python36(37))
7170
- Pip (sudo apt-get install python3-pip).
7271
- jq (sudo apt-get install jq or sudo dnf install jq)
72+
- skopeo (See [here](https://github.com/containers/skopeo/blob/main/install.md) for installation instructions or building from source)
7373

74-
Some distro versions have all of these except `attr` and/or `jq` preinstalled but both are common utilities and are available via the package manager.
74+
Some distro versions have all of these except `attr`, `jq`, and/or `skopeo` preinstalled. `attr` and `jq` are common utilities and are available via the package manager. `skopeo` has only recently been packaged for common Linux distros. If you don't see your distro in the list, your best bet is building from source, which is reasonably straightforward if you have Go installed.
7575

76-
For Docker containers
76+
For analyzing Dockerfiles and to use the "lock" function
7777
- Docker CE (Installation instructions can be found here: https://docs.docker.com/engine/installation/#server)
7878

79-
Make sure the docker daemon is running.
79+
*NOTE:* We do not provide advice on the usage of [Docker Desktop](https://www.docker.com/blog/updating-product-subscriptions/)
80+
81+
Once installed, make sure the docker daemon is running.
8082

8183
Create a python3 virtual environment:
8284
```
@@ -103,7 +105,7 @@ $ tern report -o output.txt -i debian:buster
103105
```
104106

105107
## Getting Started with Docker<a name="getting-started-with-docker">
106-
Docker is the most widely used tool to build and run containers. If you already have Docker installed, you can run Tern by building a container with the Dockerfile provided and the `docker_run.sh` script:
108+
Docker is the most widely used tool to build and run containers. If you already have Docker installed, you can run Tern by building a container with the Dockerfile provided.
107109

108110
Clone this repository:
109111
```
@@ -132,7 +134,13 @@ $ docker build -f ci/Dockerfile -t ternd .
132134
+ENTRYPOINT ["tern", "-q"]
133135
```
134136

135-
Run the script `docker_run.sh`. You may need to use sudo. In the below command `debian` is the docker hub container image name and `buster` is the tag that identifies the version we are interested in analyzing.
137+
Run the ternd container image
138+
139+
```
140+
$ docker run --rm ternd report -i debian:buster
141+
```
142+
143+
If you are using this container to analyze Dockerfiles and to use the "lock" feature, then you must volume mount the docker socket. We have a convenience script which will do that for you.
136144

137145
```
138146
$ ./docker_run.sh ternd "report -i debian:buster" > output.txt
@@ -143,15 +151,16 @@ To produce a json report run
143151
$ ./docker_run.sh ternd "report -f json -i debian:buster"
144152
```
145153

146-
What the `docker_run.sh` script does is run the built container.
147-
148154
Tern is not distributed as Docker images yet. This is coming soon. Watch the [Project Status](#project-status) for updates.
149155

150156
**WARNING**: If using the `--driver fuse` or `--driver overlay2` storage driver options, then the docker image needs to run as privileged.
157+
151158
```
152-
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock ternd "--driver fuse report -i debian:buster"
159+
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock ternd --driver fuse report -i debian:buster
153160
```
154161

162+
You can make this change to the `docker_run.sh` script to make it easier.
163+
155164
## Getting Started with Vagrant<a name="getting-started-with-vagrant">
156165
Vagrant is a tool to setup an isolated virtual software development environment. If you are using Windows or Mac OSes and want to run Tern from the command line (not in a Docker container) this is the best way to get started as Tern does not run natively in a Mac OS or Windows environment at this time.
157166

Diff for: ci/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ RUN echo "deb http://deb.debian.org/debian bullseye main" > /etc/apt/sources.lis
2424
fuse3/bullseye \
2525
git \
2626
jq \
27+
skopeo \
2728
&& rm -rf /var/lib/apt/lists/*
2829

2930
COPY --from=builder /install /usr/local

Diff for: ci/test_files_touched.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
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
from git import Repo

Diff for: docker/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RUN echo "deb http://deb.debian.org/debian bullseye main" > /etc/apt/sources.lis
2323
fuse3/bullseye \
2424
git \
2525
jq \
26+
skopeo \
2627
&& rm -rf /var/lib/apt/lists/*
2728

2829
COPY --from=builder /install /usr/local

Diff for: vagrant/Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Vagrant.configure("2") do |config|
2121

2222
# Every Vagrant development environment requires a box. You can search for
2323
# boxes at https://vagrantcloud.com/search.
24-
config.vm.box = "generic/ubuntu1804"
24+
config.vm.box = "generic/ubuntu2004"
2525
config.vm.provision :shell, path: "bootstrap.sh"
2626

2727
config.vm.synced_folder '.', '/vagrant', disabled: true

Diff for: vagrant/bootstrap.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#
3-
# Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
3+
# Copyright (c) 2018-2021 VMware, Inc. All Rights Reserved.
44
# SPDX-License-Identifier: BSD-2-Clause
55

66
# Update the Ubuntu repositories
@@ -10,7 +10,14 @@ sudo apt-get update
1010
sudo apt-get -y upgrade
1111

1212
# Python3 versions and system dependencies
13-
sudo apt-get install -y python3 python3-pip python3-venv attr
13+
sudo apt-get install -y python3 python3-pip python3-venv attr jq
14+
15+
# Install skopeo for Ubuntu 20.04
16+
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
17+
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/Release.key | sudo apt-key add -
18+
sudo apt-get update
19+
sudo apt-get -y upgrade
20+
sudo apt-get -y install skopeo
1421

1522
# Install Docker
1623
sudo apt-get install -y docker.io

0 commit comments

Comments
 (0)