summaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorAntoine Beaupré <anarcat@debian.org>2019-05-16 17:25:31 -0400
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2021-04-20 10:28:18 +0200
commitdd89d1894deb5ea266870ccd59a123e2ca15b105 (patch)
tree16180464e3fe3e52cb768d847a02540f1e662f98 /Dockerfile
parentb9e775e609d228490b3925d17b504cbea388cc29 (diff)
Add a Dockerfile to build Docker images of Sequoia.
This will make installing Sequoia easier for new users who are not familiar with Cargo or Rust toolchains. It can provide an easy, binary build for the `sq` command as well.
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile73
1 files changed, 73 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..1802e8b9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,73 @@
+# we do not use the rust image because it's based on Debian stretch
+# where nettle and rustc are too old
+FROM debian:buster AS build
+
+# create a sandbox user for the build (in ~builder) and install (in /opt)
+# give it permissions to the build dir and home
+# upgrade everything
+# add dependencies, as specified by the Sequoia README.md file
+RUN groupadd builder && \
+ useradd --no-log-init --create-home --gid builder builder && \
+ apt update && apt upgrade -yy && \
+ apt install -y --no-install-recommends \
+ ca-certificates \
+ capnproto \
+ cargo \
+ clang \
+ git \
+ libsqlite3-dev \
+ libssl-dev \
+ make \
+ nettle-dev \
+ pkg-config \
+ python3-dev \
+ python3-setuptools \
+ python3-cffi \
+ python3-pytest \
+ rustc \
+ && \
+ apt clean && \
+ chown builder /opt
+
+COPY --chown=builder:builder . /home/builder/sequoia
+
+# switch to the sandbox user
+USER builder
+
+# retry build because cargo sometimes segfaults during download (#918854)
+#
+# the `build-release` target is used instead of the default because
+# `install` calls it after anyways
+RUN cd /home/builder/sequoia && \
+ CARGO_TARGET_DIR=target cargo build -p sequoia-sqv --release && \
+ CARGO_TARGET_DIR=target cargo build -p sequoia-tool --release && \
+ install --strip -D --target-directory /opt/usr/local/bin \
+ target/release/sq \
+ target/release/sqv
+
+FROM debian:buster-slim AS sq-base
+
+RUN groupadd user && \
+ useradd --no-log-init -g user user && \
+ mkdir /home/user && \
+ chown -R user:user /home/user && \
+ apt update && apt upgrade -y && \
+ apt install -y libssl1.1 libsqlite3-0 && \
+ apt clean && \
+ rm -fr -- /var/lib/apt/lists/* /var/cache/*
+
+FROM sq-base AS sqv
+
+COPY --from=build /opt/usr/local/bin/sqv /usr/local/bin/sqv
+
+USER user
+
+WORKDIR /home/user
+ENTRYPOINT ["/usr/local/bin/sqv"]
+CMD ["--help"]
+
+FROM sqv AS sq
+
+COPY --from=build /opt/usr/local/bin/sq /usr/local/bin/sq
+
+ENTRYPOINT ["/usr/local/bin/sq"]