From de26f19f91ad39858a279cb32d36d597294f5884 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Wed, 22 Dec 2021 16:58:31 +0100 Subject: [PATCH] docker: Add helper recipe My distro RUST setup is not running it out of the box so I used a more recent one. For the record the observed error was: error[E0599]: no variant or associated item named `OutOfMemory` found for enum `ErrorKind` in the current scope -> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-core-0.5.10/src/sqlite/connection/establish.rs:107:32 Forwarded: https://github.com/astarte-platform/astarte-device-sdk-rust/pull/31 Relate-to: https://github.com/astarte-platform/astarte-device-sdk-rust/issues/20 Signed-off-by: Philippe Coval --- .dockerignore | 5 +++++ Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..13839371 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +#.dockerignore +.git/ +#.gitignore +/target +Cargo.lock diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2bfb222e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +#!/bin/echo docker build . -f +# -*- coding: utf-8 -*- +# SPDX-License-Identifier: MPL-2.0 +#{ +# Copyright: 2021+ Philippe Coval +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/ . +#} + +FROM ubuntu:22.04 +LABEL maintainer="Philippe Coval (philippe.coval@astrolabe.coop)" + +RUN echo "#log: Setup system" \ + && set -x \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + && echo "info: rust it not in main?" \ + && sed -e 's|deb \(.*\) main$|deb \1 main contrib|g' -i /etc/apt/*.list \ + && apt-get update -y \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + libssl-dev \ + pkg-config \ + cargo \ + && apt-get upgrade -y \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && date -u + +ARG project=astarte-device-sdk-rust +ARG workdir="/local/src/${project}" + +COPY . "${workdir}/" +WORKDIR "${workdir}" +RUN echo "#log: ${project}: Building sources" \ + && set -x \ + && export OPENSSL_NO_VENDOR=1 \ + && cargo build \ + && cargo install --path . \ + || cargo install --examples --path . \ + && date -u + +WORKDIR "${workdir}" +ENTRYPOINT [ "/usr/bin/cargo" ] +CMD [ "run", "--example", "simple", "--help" ]