fix: using tonistiigi/xx helpers for cross-compilation

This commit is contained in:
Shahrad Elahi 2024-09-10 02:56:37 +03:30
parent 883bfe47e8
commit 25b6704408
No known key found for this signature in database
2 changed files with 29 additions and 17 deletions

View File

@ -2,24 +2,33 @@ ARG ALPINE_VERSION=3.19
ARG LYREBIRD_VERSION=0.2.0 ARG LYREBIRD_VERSION=0.2.0
ARG NODE_VERSION=20 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 ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
RUN apk update \ COPY --from=xx / /
&& apk upgrade \ RUN xx-apk update && xx-apk upgrade && xx-apk add -U --no-cache \
&& apk add -U --no-cache \
iptables net-tools \ iptables net-tools \
screen logrotate bash \ screen logrotate bash \
wireguard-tools \ wireguard-tools \
dnsmasq \ dnsmasq \
tor \ tor \
&& xx-verify \
/bin/bash \
/usr/bin/tor \
/usr/sbin/dnsmasq \
/usr/local/bin/node \
/usr/sbin/logrotate \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*
FROM --platform=${BUILDPLATFORM} golang:alpine AS pluggables FROM --platform=${BUILDPLATFORM} golang:alpine AS pluggables
ARG TARGETPLATFORM
ARG LYREBIRD_VERSION ARG LYREBIRD_VERSION
RUN apk update \ COPY --from=xx / /
&& apk upgrade \ RUN xx-apk update && xx-apk upgrade && xx-apk add -U --no-cache \
&& apk add -U --no-cache \
bash \ bash \
make \ make \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*
@ -32,8 +41,10 @@ RUN <<EOT
wget "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/archive/lyrebird-$LYREBIRD_VERSION/lyrebird-lyrebird-$LYREBIRD_VERSION.tar.gz" wget "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/-/archive/lyrebird-$LYREBIRD_VERSION/lyrebird-lyrebird-$LYREBIRD_VERSION.tar.gz"
tar -xvf lyrebird-lyrebird-$LYREBIRD_VERSION.tar.gz tar -xvf lyrebird-lyrebird-$LYREBIRD_VERSION.tar.gz
pushd lyrebird-lyrebird-$LYREBIRD_VERSION || exit 1 pushd lyrebird-lyrebird-$LYREBIRD_VERSION || exit 1
sed -i 's/ go / xx-go /g' Makefile
make build -e VERSION=$LYREBIRD_VERSION make build -e VERSION=$LYREBIRD_VERSION
cp ./lyrebird /usr/local/bin cp ./lyrebird /usr/local/bin
xx-verify /usr/local/bin/lyrebird
popd || exit 1 popd || exit 1
cp -rv /go/bin /usr/local/bin cp -rv /go/bin /usr/local/bin
@ -47,7 +58,8 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH" ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable RUN corepack enable
COPY web . COPY web .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile \ RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --frozen-lockfile \
&& NODE_ENV=production pnpm build \ && NODE_ENV=production pnpm build \
&& pnpm prune --prod \ && pnpm prune --prod \
&& cp -R node_modules build package.json /tmp \ && cp -R node_modules build package.json /tmp \

View File

@ -1,8 +1,8 @@
ARG ALPINE_VERSION=3.19 ARG ALPINE_VERSION=3.19
ARG NODE_VERSION=20 ARG NODE_VERSION=20
FROM --platform=$BUILDPLATFORM shahradel/torproxy:latest as tor FROM --platform=$BUILDPLATFORM shahradel/torproxy:latest AS tor
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine${ALPINE_VERSION} as node FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS node
ENV TZ=UTC ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apk update \ RUN apk update \