Skip to content

Commit

Permalink
Native cross compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Sep 17, 2021
1 parent e28d7d2 commit b587c42
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
ARG MSMTP_VERSION=1.8.16
ARG ALPINE_S6_VERSION=3.14-2.2.0.3
ARG XX_VERSION=1.0.0-rc.2

FROM --platform=${BUILDPLATFORM:-linux/amd64} crazymax/alpine-s6:3.14-2.2.0.3 AS download
RUN apk --update --no-cache add curl tar unzip xz
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM crazymax/alpine-s6:${ALPINE_S6_VERSION} AS builder
RUN apk --update --no-cache add \
clang \
curl \
pkgconf \
tar \
unzip \
xz \
&& rm -rf /tmp/*

ARG MSMTP_VERSION
WORKDIR /dist/msmtp
WORKDIR /src
RUN curl -sSL "https://marlam.de/msmtp/releases/msmtp-$MSMTP_VERSION.tar.xz" | tar xJv --strip 1

FROM crazymax/alpine-s6:3.14-2.2.0.3 AS builder
RUN apk --update --no-cache add \
autoconf \
automake \
binutils \
build-base \
ARG TARGETPLATFORM
ENV XX_CC_PREFER_LINKER=ld
COPY --from=xx / /
RUN xx-apk --no-cache add \
file \
g++ \
gettext-dev \
gnutls-dev \
libc-dev \
libidn2-dev \
libgsasl-dev \
libsecret-dev \
openssl-dev \
&& rm -rf /tmp/*

COPY --from=download /dist/msmtp /tmp/msmtp
WORKDIR /tmp/msmtp
RUN ./configure \
make
RUN set -x \
&& ./configure \
--host=$(xx-clang --print-target-triple) \
--prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--localstatedir=/var \
&& make -j$(nproc) \
&& make install \
&& msmtp --version
&& make install
RUN msmtp --version

FROM crazymax/alpine-s6:3.14-2.2.0.3
FROM crazymax/alpine-s6:${ALPINE_S6_VERSION}

ENV S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
TZ="UTC" \
Expand All @@ -51,7 +60,6 @@ RUN apk --update --no-cache add \
libgsasl \
libsecret \
mailx \
openssl \
shadow \
tzdata \
&& ln -sf /usr/bin/msmtp /usr/sbin/sendmail \
Expand Down

0 comments on commit b587c42

Please sign in to comment.