Skip to content

Commit

Permalink
cross compile
Browse files Browse the repository at this point in the history
  • Loading branch information
aieu committed Dec 5, 2024
1 parent dd48b20 commit eaa0ba5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/v2ray-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
version:
description: 'version'
required: true
default: '5.17.0'
default: '1.3.2'

jobs:
build:
Expand Down
6 changes: 4 additions & 2 deletions frp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CGO_ENABLED=on
ARG CGO_ENABLED=off

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -13,7 +13,9 @@ RUN apk add --no-cache curl build-base git libcap && \
mkdir -p /root/frp && cd /root/frp && \
curl -sSL https://github.com/fatedier/frp/archive/v$VERSION.tar.gz | \
tar xz --strip 1 && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 && \
go build -v -ldflags "-s -w" -o /frps ./cmd/frps && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 && \
go build -v -ldflags "-s -w" -o /frpc ./cmd/frpc && \
ls /frp* | xargs -n1 setcap 'cap_net_bind_service+ep' && \
cp ./conf/frp* /etc/
Expand Down
1 change: 0 additions & 1 deletion shadowsocks/rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,4 @@ CMD ssserver \
-m $METHOD \
--timeout $TIMEOUT \
--dns $DNS_ADDR \
--tcp-no-delay \
-U
14 changes: 10 additions & 4 deletions shadowsocks/v2ray-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CGO_ENABLED=on
ARG CGO_ENABLED=off

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -17,9 +17,13 @@ RUN set -xe && \
build-base \
git \
libcap && \
mkdir -p /root/plugin && cd /root/plugin && \
curl -sSL https://github.com/teddysun/v2ray-plugin/archive/v$VERSION.tar.gz | \
mkdir -p /root/v2ray-plugin && cd $_ && \
curl -sSL https://github.com/shadowsocks/v2ray-plugin/archive/v$VERSION.tar.gz | \
tar xz --strip 1 && \
for i in "8088262" "b9770e8" "350f7cb" "467a55e" "e9af1cd"; do \
curl -sSL https://github.com/shadowsocks/v2ray-plugin/commit/$i.patch | patch -p1; \
done && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build -v -trimpath -ldflags "-X main.VERSION=v$VERSION -s -w -buildid=" -o /v2ray-plugin && \
setcap 'cap_net_bind_service=+ep' /v2ray-plugin

Expand All @@ -28,4 +32,6 @@ FROM alpine:3

COPY --from=builder /v2ray-plugin /usr/bin/

SHELL ["/bin/sh", "-c"]

CMD v2ray-plugin -version
5 changes: 3 additions & 2 deletions shadowsocks/xray-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CGO_ENABLED=on
ARG CGO_ENABLED=off

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -20,6 +20,7 @@ RUN set -xe && \
mkdir -p /root/plugin && cd /root/plugin && \
curl -sSL https://github.com/teddysun/xray-plugin/archive/v$VERSION.tar.gz | \
tar xz --strip 1 && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build -v -ldflags "-X main.VERSION=$VERSION -s -w" -gcflags "" -o /xray-plugin && \
setcap 'cap_net_bind_service=+ep' /xray-plugin

Expand Down
5 changes: 3 additions & 2 deletions trojan-go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CGO_ENABLED=on
ARG CGO_ENABLED=off

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -20,6 +20,7 @@ RUN set -xe && \
curl -sSL https://github.com/p4gefau1t/trojan-go/archive/v$VERSION.tar.gz | \
tar xz --strip 1 && \
mkdir release && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build -v -tags "full" -ldflags "-s -w" -o release && \
setcap 'cap_net_bind_service=+ep' ./release/trojan-go && \
curl -sSL https://github.com/v2fly/geoip/raw/release/geoip.dat -o release/geoip.dat && \
Expand Down
5 changes: 3 additions & 2 deletions v2ray/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CGO_ENABLED=on
ARG CGO_ENABLED=off

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -19,6 +19,7 @@ RUN set -xe && \
cd /root/v2ray-src && \
curl -sSL https://github.com/v2fly/v2ray-core/archive/v$VERSION.tar.gz | tar xz --strip 1 && \
LDFLAGS="-s -w -buildid= -X github.com/v2fly/v2ray-core/v5.codename=user -X github.com/v2fly/v2ray-core/v5.build=$(date '+%Y%m%d-%H%M%S') -X github.com/v2fly/v2ray-core/v5.version=v$VERSION" && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build -ldflags "$LDFLAGS" -v -o /v2ray ./main && \
ls /v2* | xargs -n1 setcap 'cap_net_bind_service=+ep' && \
curl -sSL https://github.com/v2ray/geoip/raw/release/geoip.dat -o /geoip.dat && \
Expand Down
5 changes: 3 additions & 2 deletions xray/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM golang:alpine AS builder

ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG CGO_ENABLED=on
ARG CGO_ENABLED=off

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -19,6 +19,7 @@ RUN set -xe && \
cd /root/xray-src && \
curl -sSL https://github.com/XTLS/Xray-core/archive/v$VERSION.tar.gz | tar xz --strip 1 && \
LDFLAGS="-s -w -buildid=" && \
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build -v -o /xray -trimpath -ldflags "$LDFLAGS" ./main && \
setcap 'cap_net_bind_service=+ep' /xray && \
curl -sSL https://github.com/v2ray/geoip/raw/release/geoip.dat -o /geoip.dat && \
Expand Down

0 comments on commit eaa0ba5

Please sign in to comment.