From 25b6704408754fcd1faad9bb21a3681751635cab Mon Sep 17 00:00:00 2001 From: Shahrad Elahi Date: Tue, 10 Sep 2024 02:56:37 +0330 Subject: [PATCH] fix: using `tonistiigi/xx` helpers for cross-compilation --- Dockerfile | 42 +++++++++++++++++++++++++++--------------- Dockerfile-Dev | 4 ++-- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a5c642..ff32e89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,26 +2,35 @@ ARG ALPINE_VERSION=3.19 ARG LYREBIRD_VERSION=0.2.0 ARG NODE_VERSION=20 -FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine${ALPINE_VERSION} as node +# Get Dockerfile cross-compilation helpers. +FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx + +FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS node +ARG TARGETPLATFORM ENV TZ=UTC RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone -RUN apk update \ - && apk upgrade \ - && apk add -U --no-cache \ - iptables net-tools \ - screen logrotate bash \ - wireguard-tools \ - dnsmasq \ - tor \ +COPY --from=xx / / +RUN xx-apk update && xx-apk upgrade && xx-apk add -U --no-cache \ + iptables net-tools \ + screen logrotate bash \ + wireguard-tools \ + dnsmasq \ + tor \ + && xx-verify \ + /bin/bash \ + /usr/bin/tor \ + /usr/sbin/dnsmasq \ + /usr/local/bin/node \ + /usr/sbin/logrotate \ && rm -rf /var/cache/apk/* FROM --platform=${BUILDPLATFORM} golang:alpine AS pluggables +ARG TARGETPLATFORM ARG LYREBIRD_VERSION -RUN apk update \ - && apk upgrade \ - && apk add -U --no-cache \ - bash \ - make \ +COPY --from=xx / / +RUN xx-apk update && xx-apk upgrade && xx-apk add -U --no-cache \ + bash \ + make \ && rm -rf /var/cache/apk/* SHELL ["/bin/bash", "-c"] RUN < /etc/timezone RUN apk update \