diff --git a/docker/brook/Dockerfile b/docker/brook/Dockerfile index 640b744..8d42ad1 100644 --- a/docker/brook/Dockerfile +++ b/docker/brook/Dockerfile @@ -1,17 +1,20 @@ # Dockerfile for Brook based alpine -# Copyright (C) 2019 Teddysun +# Copyright (C) 2019 - 2020 Teddysun # Reference URL: # https://github.com/txthinking/brook -FROM golang:alpine as builder -RUN set -ex && apk add --update git \ - && go get -u -v github.com/txthinking/brook/cli/brook - FROM alpine:latest LABEL maintainer="Teddysun " -COPY --from=builder /go/bin/brook /usr/bin +WORKDIR /root +COPY brook.sh /root/brook.sh +RUN set -ex \ + && apk add --no-cache tzdata \ + && chmod +x /root/brook.sh \ + && /root/brook.sh \ + && rm -fv /root/brook.sh +ENV TZ=Asia/Shanghai ENV ARGS="server -l :9000 -p password0" CMD brook $ARGS diff --git a/docker/brook/Dockerfile.architecture b/docker/brook/Dockerfile.architecture index d705b20..2ec5999 100644 --- a/docker/brook/Dockerfile.architecture +++ b/docker/brook/Dockerfile.architecture @@ -3,15 +3,19 @@ # Reference URL: # https://github.com/txthinking/brook -FROM --platform=$TARGETPLATFORM golang:alpine as builder -RUN set -ex && apk add --update git \ - && go get -u -v github.com/txthinking/brook/cli/brook - -FROM --platform=$TARGETPLATFORM alpine:latest +FROM --platform=${TARGETPLATFORM} alpine:latest LABEL maintainer="Teddysun " -COPY --from=builder /go/bin/brook /usr/bin +ARG TARGETPLATFORM +WORKDIR /root +COPY brook.sh /root/brook.sh +RUN set -ex \ + && apk add --no-cache tzdata \ + && chmod +x /root/brook.sh \ + && /root/brook.sh "${TARGETPLATFORM}" \ + && rm -fv /root/brook.sh +ENV TZ=Asia/Shanghai ENV ARGS="server -l :9000 -p password0" CMD brook $ARGS diff --git a/docker/brook/brook.sh b/docker/brook/brook.sh new file mode 100644 index 0000000..13aa991 --- /dev/null +++ b/docker/brook/brook.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# +# This is a Shell script for brook based alpine with Docker image +# +# Copyright (C) 2019 - 2020 Teddysun +# +# Reference URL: +# https://github.com/txthinking/brook + +PLATFORM=$1 +if [ -z "$PLATFORM" ]; then + ARCH="amd64" +else + case "$PLATFORM" in + linux/386) + ARCH="386" + ;; + linux/amd64) + ARCH="amd64" + ;; + linux/arm/v6) + ARCH="arm6" + ;; + linux/arm/v7) + ARCH="arm7" + ;; + linux/arm64|linux/arm64/v8) + ARCH="arm64" + ;; + linux/ppc64le) + ARCH="ppc64le" + ;; + linux/s390x) + ARCH="s390x" + ;; + *) + ARCH="" + ;; + esac +fi +[ -z "${ARCH}" ] && echo "Error: Not supported OS Architecture" && exit 1 +# Download binary file +BROOK_FILE="brook_linux_${ARCH}" +echo "Downloading binary file: ${BROOK_FILE}" +wget -O /usr/bin/brook https://dl.lamp.sh/files/${BROOK_FILE} > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "Error: Failed to download binary file: ${BROOK_FILE}" && exit 1 +fi +chmod +x /usr/bin/brook +echo "Download binary file: ${BROOK_FILE} completed"