Skip to content

Commit 44fe4f5

Browse files
author
Jonathan Claudius
authored
Add docker pinning (#188)
* Add docker pinning * Add ubuntu docker pin * Add workflow to enforce docker pinning * Remove copy pasta from script
1 parent 96dc37f commit 44fe4f5

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.github/workflows/docker.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
env:
99
SOLANA_VERSION: 1.10.29
10+
SOLANA_DOCKER_IMAGE_HASH: 78900501ccd1ade1bf088fa0830c46bc6095c6799469ff9b335e1f02d957e53a
1011
DOCKER_HUB: docker.io
1112
DOCKER_USER: ${{ secrets.DOCKER_IO_USER }}
1213
IS_RELEASE: ${{
@@ -35,6 +36,7 @@ jobs:
3536
docker build \
3637
--file docker/Dockerfile \
3738
--build-arg SOLANA_VERSION="${SOLANA_VERSION}" \
39+
--build-arg SOLANA_DOCKER_IMAGE_HASH="${SOLANA_DOCKER_IMAGE_HASH}" \
3840
--tag "${DOCKER_IMAGE}" \
3941
.
4042
@@ -49,3 +51,10 @@ jobs:
4951
docker image push "${PUB_IMAGE}"
5052
}
5153
echo "${{ secrets.DOCKER_IO_PASS }}" | publish
54+
pinning:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Check out source
58+
uses: actions/checkout@v2
59+
- run: chmod 755 ./scripts/check-docker-pin.sh
60+
- run: ./scripts/check-docker-pin.sh

docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ARG SOLANA_VERSION
2-
FROM solanalabs/solana:v${SOLANA_VERSION}
2+
ARG SOLANA_DOCKER_IMAGE_HASH
3+
FROM solanalabs/solana:v${SOLANA_VERSION}@sha256:${SOLANA_DOCKER_IMAGE_HASH}
34

45
# Redeclare SOLANA_VERSION in the new build stage.
56
# Persist in env for docker run & inspect.

docker/fuzz/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:20.04@sha256:fd92c36d3cb9b1d027c4d2a72c6bf0125da82425fc2ca37c414d4f010180dc19
22

33
ENV DEBIAN_FRONTEND=noninteractive
44
RUN apt-get update

scripts/check-docker-pin.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
# This script is checks to that all our Docker images are pinned to a specific SHA256 hash
4+
#
5+
# References as to why...
6+
# - https://nickjanetakis.com/blog/docker-tip-18-please-pin-your-docker-image-versions
7+
# - https://snyk.io/blog/10-docker-image-security-best-practices/ (Specifically: USE FIXED TAGS FOR IMMUTABILITY)
8+
#
9+
# Explaination of regex ignore choices
10+
# - We ignore sha256 because it suggests that the image dep is pinned
11+
# - We ignore scratch because it's literally the docker base image
12+
#
13+
git ls-files | grep "Dockerfile*" | xargs grep -s "FROM" | egrep -v 'sha256|scratch'
14+
if [ $? -eq 0 ]; then
15+
echo "[!] Unpinned docker files" >&2
16+
exit 1
17+
else
18+
echo "[+] No unpinned docker files"
19+
fi

0 commit comments

Comments
 (0)