CI: Add Go proxy
This commit is contained in:
parent
714e65d2da
commit
4def62fb1e
10 changed files with 63 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM photoprism/development:20211203
|
||||
FROM photoprism/development:20211209
|
||||
|
||||
# Copy latest entrypoint script
|
||||
COPY --chown=root:root /docker/development/entrypoint.sh /entrypoint.sh
|
||||
|
|
3
Makefile
3
Makefile
|
@ -209,6 +209,9 @@ docker-local:
|
|||
scripts/docker-build.sh photoprism
|
||||
docker-pull:
|
||||
docker pull photoprism/photoprism:latest
|
||||
docker-goproxy:
|
||||
scripts/docker-build.sh goproxy $(DOCKER_TAG)
|
||||
scripts/docker-push.sh goproxy $(DOCKER_TAG)
|
||||
docker-demo:
|
||||
scripts/docker-build.sh demo $(DOCKER_TAG)
|
||||
scripts/docker-push.sh demo $(DOCKER_TAG)
|
||||
|
|
|
@ -17,6 +17,7 @@ services:
|
|||
- "~/.cache/npm:/root/.cache/npm"
|
||||
- "~/.cache/go-mod:/go/pkg/mod"
|
||||
environment:
|
||||
GOPROXY: ${GOPROXY:-http://goproxy:8888,direct}
|
||||
PHOTOPRISM_SITE_URL: "http://localhost:2342/"
|
||||
PHOTOPRISM_SITE_TITLE: "PhotoPrism"
|
||||
PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
|
||||
|
|
|
@ -22,6 +22,7 @@ services:
|
|||
- "2343:2343" # Acceptance Test HTTP port (host:container)
|
||||
shm_size: "2gb"
|
||||
environment:
|
||||
GOPROXY: ${PHOTOPRISM_GOPROXY:-http://goproxy:8888,direct}
|
||||
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # The initial admin password (min 4 characters)
|
||||
PHOTOPRISM_UID: ${UID:-1000}
|
||||
PHOTOPRISM_GID: ${GID:-1000}
|
||||
|
@ -126,6 +127,14 @@ services:
|
|||
WEBDAV_USERNAME: admin
|
||||
WEBDAV_PASSWORD: photoprism
|
||||
|
||||
## Proxy for Go Modules
|
||||
goproxy:
|
||||
image: photoprism/goproxy:latest
|
||||
ports:
|
||||
- "8888:8888"
|
||||
volumes:
|
||||
- "./storage/go:/go"
|
||||
|
||||
volumes:
|
||||
go-mod:
|
||||
driver: local
|
||||
|
|
|
@ -5,6 +5,7 @@ LABEL maintainer="Michael Mayer <hello@photoprism.org>"
|
|||
ARG TARGETARCH
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILD_TAG
|
||||
ARG GOPROXY
|
||||
|
||||
# Set environment variables
|
||||
ENV DEBIAN_FRONTEND="noninteractive" \
|
||||
|
|
24
docker/goproxy/Dockerfile
Normal file
24
docker/goproxy/Dockerfile
Normal file
|
@ -0,0 +1,24 @@
|
|||
FROM golang:alpine AS build
|
||||
|
||||
RUN apk add --no-cache -U make git mercurial subversion
|
||||
|
||||
RUN git clone https://github.com/goproxyio/goproxy.git /src/goproxy && \
|
||||
cd /src/goproxy && \
|
||||
export CGO_ENABLED=0 && \
|
||||
make
|
||||
|
||||
FROM golang:alpine
|
||||
|
||||
ENV TINI_VERSION v0.19.0
|
||||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-amd64 /usr/bin/tini
|
||||
RUN chmod +x /usr/bin/tini
|
||||
|
||||
RUN apk add --no-cache -U git mercurial subversion
|
||||
|
||||
COPY --from=build /src/goproxy/bin/goproxy /goproxy
|
||||
VOLUME "/go"
|
||||
|
||||
EXPOSE 8888
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/goproxy", "-listen", "0.0.0.0:8888"]
|
|
@ -1,8 +1,9 @@
|
|||
FROM photoprism/development:20211203 as build
|
||||
FROM photoprism/development:20211209 as build
|
||||
|
||||
ARG TARGETARCH
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILD_TAG
|
||||
ARG GOPROXY
|
||||
|
||||
# Set up project directory
|
||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||
|
|
|
@ -44,7 +44,9 @@ elif [[ $1 == "static" ]]; then
|
|||
echo "Done."
|
||||
else
|
||||
echo "Building production binary..."
|
||||
go build -ldflags "-s -w -X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}" -o $2 cmd/photoprism/photoprism.go
|
||||
for i in {1..3}; do
|
||||
echo "Attempt $i" && go build -ldflags "-s -w -X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}" -o $2 cmd/photoprism/photoprism.go && break || sleep 5;
|
||||
done
|
||||
du -h $2
|
||||
echo "Done."
|
||||
fi
|
||||
|
|
|
@ -5,16 +5,29 @@ set -e
|
|||
# see https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
GOPROXY=${GOPROXY:-'https://goproxy.io,direct'}
|
||||
|
||||
if [[ -z $1 ]] && [[ -z $2 ]]; then
|
||||
echo "Please provide a container image name and version" 1>&2
|
||||
exit 1
|
||||
elif [[ $1 ]] && [[ -z $2 ]]; then
|
||||
DOCKER_TAG=$(date -u +%Y%m%d)
|
||||
echo "Building 'photoprism/$1:preview'...";
|
||||
docker build --no-cache --build-arg BUILD_TAG="${DOCKER_TAG}" -t photoprism/$1:preview -f docker/${1/-//}/Dockerfile .
|
||||
docker build \
|
||||
--no-cache \
|
||||
--build-arg BUILD_TAG="${DOCKER_TAG}" \
|
||||
--build-arg GOPROXY \
|
||||
-t photoprism/$1:preview \
|
||||
-f docker/${1/-//}/Dockerfile .
|
||||
echo "Done"
|
||||
else
|
||||
echo "Building 'photoprism/$1:$2'...";
|
||||
docker build --no-cache --build-arg BUILD_TAG=$2 -t photoprism/$1:latest -t photoprism/$1:$2 -f docker/${1/-//}/Dockerfile .
|
||||
docker build \
|
||||
--no-cache \
|
||||
--build-arg BUILD_TAG=$2 \
|
||||
--build-arg GOPROXY \
|
||||
-t photoprism/$1:latest \
|
||||
-t photoprism/$1:$2 \
|
||||
-f docker/${1/-//}/Dockerfile .
|
||||
echo "Done"
|
||||
fi
|
||||
|
|
|
@ -8,6 +8,8 @@ if [[ -z $1 ]] || [[ -z $2 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
GOPROXY=${GOPROXY:-'https://goproxy.io,direct'}
|
||||
|
||||
echo "Removing existing multibuilder..."
|
||||
docker buildx rm multibuilder 2>/dev/null
|
||||
sleep 3
|
||||
|
@ -23,6 +25,7 @@ if [[ $1 ]] && [[ $2 ]] && [[ -z $3 ]]; then
|
|||
--pull \
|
||||
--no-cache \
|
||||
--build-arg BUILD_TAG=$DOCKER_TAG \
|
||||
--build-arg GOPROXY \
|
||||
-f docker/$1/Dockerfile \
|
||||
-t photoprism/$1:preview \
|
||||
--push .
|
||||
|
@ -33,6 +36,7 @@ else
|
|||
--pull \
|
||||
--no-cache \
|
||||
--build-arg BUILD_TAG=$3 \
|
||||
--build-arg GOPROXY \
|
||||
-f docker/$1/Dockerfile \
|
||||
-t photoprism/$1:latest \
|
||||
-t photoprism/$1:$3 \
|
||||
|
|
Loading…
Add table
Reference in a new issue