From da0d23f3d12038eb67fdaf355b2abe252158706b Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Mon, 10 Jul 2023 15:19:02 +1000 Subject: [PATCH] Unified Dockerfile --- .dockerignore | 2 +- .github/workflows/docker-buildx-dev.yml | 12 +++--- .github/workflows/docker-buildx-latest.yml | 12 +++--- Dockerfile.amd64 => Dockerfile | 0 Dockerfile.arm | 43 ---------------------- Dockerfile.arm64 | 43 ---------------------- README.md | 22 +++-------- 7 files changed, 18 insertions(+), 116 deletions(-) rename Dockerfile.amd64 => Dockerfile (100%) delete mode 100644 Dockerfile.arm delete mode 100644 Dockerfile.arm64 diff --git a/.dockerignore b/.dockerignore index 6deb67c..f77b53a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,6 @@ ** # Allow only docker duild files -!Dockerfile.* +!Dockerfile !*.sh !*.tpl \ No newline at end of file diff --git a/.github/workflows/docker-buildx-dev.yml b/.github/workflows/docker-buildx-dev.yml index 1d063e6..94f4b77 100644 --- a/.github/workflows/docker-buildx-dev.yml +++ b/.github/workflows/docker-buildx-dev.yml @@ -41,7 +41,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.amd64 + file: ./Dockerfile platforms: | linux/amd64 linux/arm64 @@ -54,7 +54,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.amd64 + file: ./Dockerfile platforms: linux/amd64 push: true tags: ${{ github.repository }}:amd64dev @@ -63,7 +63,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.arm64 + file: ./Dockerfile platforms: linux/arm64 push: true tags: ${{ github.repository }}:arm64dev @@ -72,7 +72,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.arm + file: ./Dockerfile platforms: linux/arm/v7 push: true tags: ${{ github.repository }}:armv7dev @@ -81,7 +81,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.arm + file: ./Dockerfile platforms: linux/arm/v6 push: true - tags: ${{ github.repository }}:armdev + tags: ${{ github.repository }}:armv6dev diff --git a/.github/workflows/docker-buildx-latest.yml b/.github/workflows/docker-buildx-latest.yml index 7d118ef..8e9348b 100644 --- a/.github/workflows/docker-buildx-latest.yml +++ b/.github/workflows/docker-buildx-latest.yml @@ -41,7 +41,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.amd64 + file: ./Dockerfile platforms: | linux/amd64 linux/arm64 @@ -54,7 +54,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.amd64 + file: ./Dockerfile platforms: linux/amd64 push: true tags: ${{ github.repository }}:amd64 @@ -63,7 +63,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.arm64 + file: ./Dockerfile platforms: linux/arm64 push: true tags: ${{ github.repository }}:arm64 @@ -72,7 +72,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.arm + file: ./Dockerfile platforms: linux/arm/v7 push: true tags: ${{ github.repository }}:armv7 @@ -81,7 +81,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfile.arm + file: ./Dockerfile platforms: linux/arm/v6 push: true - tags: ${{ github.repository }}:arm + tags: ${{ github.repository }}:armv6 diff --git a/Dockerfile.amd64 b/Dockerfile similarity index 100% rename from Dockerfile.amd64 rename to Dockerfile diff --git a/Dockerfile.arm b/Dockerfile.arm deleted file mode 100644 index 6e2e6a7..0000000 --- a/Dockerfile.arm +++ /dev/null @@ -1,43 +0,0 @@ -FROM arm32v6/golang:1.19-alpine as builder - -ARG XRAYVER='v1.7.2' - -RUN apk add --no-cache bash git build-base - -WORKDIR /go/src/XTLS/Xray-core -RUN git clone https://github.com/XTLS/Xray-core.git . && \ - git checkout ${XRAYVER} && \ - go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main - - -FROM arm32v6/alpine:3.17 - -ARG ACMEVER='2.9.0' - -COPY --from=builder /go/src/XTLS/Xray-core/xray /usr/local/bin/ - -RUN apk update && apk add bash nginx openssl curl socat jq moreutils -RUN cd /root; curl -sSL "https://github.com/acmesh-official/acme.sh/archive/refs/tags/${ACMEVER}.tar.gz"|tar zxvf - -RUN cd /root; mv acme.sh-${ACMEVER} .acme.sh - -COPY site-ssl.conf.tpl /etc/nginx/http.d/ -COPY grpc.tpl /etc/nginx/http.d/ -COPY ws.tpl /etc/nginx/http.d/ -ADD run.sh /run.sh -ADD server-ltx.sh /server-ltx.sh -ADD server-ltt.sh /server-ltt.sh -ADD server-lttw.sh /server-lttw.sh -ADD server-ltpw.sh /server-ltpw.sh -ADD server-mtt.sh /server-mtt.sh -ADD server-mttw.sh /server-mttw.sh -ADD server-mtpw.sh /server-mtpw.sh -ADD server-ttt.sh /server-ttt.sh -ADD server-tttw.sh /server-tttw.sh -ADD server-ttpw.sh /server-ttpw.sh -ADD server-lttg.sh /server-lttg.sh -ADD server-ltpg.sh /server-ltpg.sh -ADD server-nginx.sh /server-nginx.sh - -RUN chmod 755 /*.sh - -ENTRYPOINT ["/run.sh"] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index 7b43954..0000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -1,43 +0,0 @@ -FROM arm64v8/golang:1.19-alpine as builder - -ARG XRAYVER='v1.7.2' - -RUN apk add --no-cache bash git build-base - -WORKDIR /go/src/XTLS/Xray-core -RUN git clone https://github.com/XTLS/Xray-core.git . && \ - git checkout ${XRAYVER} && \ - go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main - - -FROM arm64v8/alpine:3.17 - -ARG ACMEVER='2.9.0' - -COPY --from=builder /go/src/XTLS/Xray-core/xray /usr/local/bin/ - -RUN apk update && apk add bash nginx openssl curl socat jq moreutils -RUN cd /root; curl -sSL "https://github.com/acmesh-official/acme.sh/archive/refs/tags/${ACMEVER}.tar.gz"|tar zxvf - -RUN cd /root; mv acme.sh-${ACMEVER} .acme.sh - -COPY site-ssl.conf.tpl /etc/nginx/http.d/ -COPY grpc.tpl /etc/nginx/http.d/ -COPY ws.tpl /etc/nginx/http.d/ -ADD run.sh /run.sh -ADD server-ltx.sh /server-ltx.sh -ADD server-ltt.sh /server-ltt.sh -ADD server-lttw.sh /server-lttw.sh -ADD server-ltpw.sh /server-ltpw.sh -ADD server-mtt.sh /server-mtt.sh -ADD server-mttw.sh /server-mttw.sh -ADD server-mtpw.sh /server-mtpw.sh -ADD server-ttt.sh /server-ttt.sh -ADD server-tttw.sh /server-tttw.sh -ADD server-ttpw.sh /server-ttpw.sh -ADD server-lttg.sh /server-lttg.sh -ADD server-ltpg.sh /server-ltpg.sh -ADD server-nginx.sh /server-nginx.sh - -RUN chmod 755 /*.sh - -ENTRYPOINT ["/run.sh"] diff --git a/README.md b/README.md index 587cb22..eb3d3ef 100644 --- a/README.md +++ b/README.md @@ -285,31 +285,19 @@ $ docker run --rm -p 80:80 -p 443:443 samuelhbne/server-xray \ ```shell $ git clone https://github.com/samuelhbne/server-xray.git $ cd server-xray -$ docker build -t samuelhbne/server-xray -f Dockerfile.amd64 . +$ docker build -t samuelhbne/server-xray . ... ``` -### NOTE 5 - -Please replace "amd64" with the arch match the current box accordingly. Other supported platforms: - -- "arm64" for arm64v8 platforms. Support AWS A1, t4g instances as well as Apple M1, Raspberry Pi4 with 64bits OS like [Ubuntu arm64](https://ubuntu.com/download/raspberry-pi) or [Debian](https://raspi.debian.net/tested-images/). -- "arm" for arm32v7 platforms. Support most Raspberry-Pi releases (Pi2, Pi3, Pi4) with 32bits OS like [Ubuntu armhf](https://ubuntu.com/download/raspberry-pi), [Debian](https://raspi.debian.net/tested-images/) or [Raspberry Pi OS](https://www.raspberrypi.org/software/operating-systems/). - -### NOTE 6 - -- arm32v6 (Pi1 and Pi-zero) users should build the docker images from source rather than run it directly, due to the known issue from upstream Alpine image. WIP. -- arm32v5 platforms are not supported yet. - ### Cross-compile docker image for the platforms with different architecture Please refer the [official doc](https://github.com/docker/buildx) for docker-buildx installation ```shell -docker buildx build --platform=linux/arm/v7 -t samuelhbne/server-xray:armv7 -f Dockerfile.arm . -docker buildx build --platform=linux/arm/v6 -t samuelhbne/server-xray:armv6 -f Dockerfile.arm . -docker buildx build --platform=linux/arm64 -t samuelhbne/server-xray:arm64 -f Dockerfile.arm64 . -docker buildx build --platform=linux/amd64 -t samuelhbne/server-xray:amd64 -f Dockerfile.amd64 . +docker buildx build --platform=linux/arm/v7 -t samuelhbne/server-xray:armv7 . +docker buildx build --platform=linux/arm/v6 -t samuelhbne/server-xray:armv6 . +docker buildx build --platform=linux/arm64 -t samuelhbne/server-xray:arm64 . +docker buildx build --platform=linux/amd64 -t samuelhbne/server-xray:amd64 . ``` ## Credits