Skip to content

Commit

Permalink
docker: Add helper recipe
Browse files Browse the repository at this point in the history
Using official rust's docker image as base.

Usage is straight forward:

```
    docker run astarte-device-sdk-rust:latest run --example simple -- \
	   --credentials-secret $credentialssecret \
	   --device-id $deviceid \
	   --pairing-url $pairingurl \
	   --realm $realm
```

For the record it can be rebased on ubuntu:21.10
(and cargo should be added to base packages)

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

Install example is needed because there is no default installation rule:

  error: there is nothing to install in `astarte_sdk v0.1.0 (/local/src/astarte-device-sdk-rust)`, because it has no binaries

Forwarded: #31
Relate-to: #20
Signed-off-by: Philippe Coval <[email protected]>
  • Loading branch information
rzr committed Feb 28, 2022
1 parent f0c6fe5 commit c184760
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2022 Huawei OSTC
#
# SPDX-License-Identifier: CC0-1.0

#.dockerignore
.git/
#.gitignore
/target
Cargo.lock
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/echo docker build . -f
# -*- coding: utf-8 -*-
# Copyright 2022 Huawei OTC
#
# SPDX-License-Identifier: Apache-2.0

FROM rust:bullseye
LABEL maintainer="Philippe Coval ([email protected])"

RUN echo "#log: Setup system" \
&& set -x \
&& apt-get update \
&& apt-get install -y \
--no-install-recommends \
ca-certificates \
libssl-dev \
pkg-config \
&& 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 . || echo "warning: no default install rule" \
&& cargo install --examples --path . \
&& date -u

WORKDIR "${workdir}"
ENTRYPOINT [ "cargo" ]
CMD [ "run", "--example", "simple", "--" , "--help" ]

0 comments on commit c184760

Please sign in to comment.