From 2f87b4131c9fb21cac053ab1a29b7833d1b6e67c Mon Sep 17 00:00:00 2001
From: Gilles Filippini <pini@debian.org>
Date: Sun, 16 Jan 2022 02:02:07 +0100
Subject: [PATCH] build (docker): build for Debian buster

Because the CI jobs use the paritytech/ci-linux image (debian based),
maintained by the substrate developers, and which contains everything it
does to do CI stuff on a substrate project.

Remove RUSTFLAGS environment variable as it is needed for Alpine Linux
only.
---
 docker/Dockerfile        | 39 +++++++++++----------------------------
 docker/docker-entrypoint |  2 +-
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/docker/Dockerfile b/docker/Dockerfile
index fa682b4dc..08a77ab1b 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -2,50 +2,33 @@
 # Build Stage
 # ------------------------------------------------------------------------------
 
-FROM alpine as build
-
-RUN apk update && \
-	apk add ca-certificates curl && \
-	update-ca-certificates && \
-	apk add --update \
-		cmake \
-		make \
-		pkgconfig \
-		gcc \
-		g++ \
-		musl-dev \
-		linux-headers \
-		protoc \
-		openssl-dev \
-		clang-dev
-
-# install latest stable rust
-RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
+# Building for Debian buster because we need the binary to be compatible
+# with the image paritytech/ci-linux:production (currently based on
+# debian:buster-slim) used by the gitlab CI
+FROM rust:1-buster as build
+
+RUN apt-get update && \
+    DEBIAN_FRONTEND=noninteractive apt-get install -y \
+        clang
 
 # Copy source tree
 COPY . .
 
 # build duniter
 ARG threads=1
-RUN source ~/.cargo/env && \
-	CARGO_PROFILE_RELEASE_LTO="true" \
-	RUSTFLAGS="-C target-feature=-crt-static" \
-		cargo build --release -j $threads
+RUN CARGO_PROFILE_RELEASE_LTO="true" \
+        cargo build --release -j $threads
 
 # ------------------------------------------------------------------------------
 # Final Stage
 # ------------------------------------------------------------------------------
 
-FROM alpine
+FROM debian:buster-slim
 
 LABEL maintainer="Gilles Filippini <gilles.filippini@pini.fr>"
 LABEL version="0.0.0"
 LABEL description="Crypto-currency software (based on Substrate framework) to operate Äž1 libre currency"
 
-# Dependancies
-RUN apk update && \
-    apk add libstdc++
-
 # Intall
 COPY --from=build /target/release/duniter /usr/local/bin/duniter
 COPY docker/docker-entrypoint /usr/local/bin/
diff --git a/docker/docker-entrypoint b/docker/docker-entrypoint
index e83075f56..1fb42dd55 100755
--- a/docker/docker-entrypoint
+++ b/docker/docker-entrypoint
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 function boolean () {
   echo "$1" | sed -E 's/^(true|yes|1)$/true/i'
-- 
GitLab