- Change NEXT_PUBLIC_ENTE_ENDPOINT from "/api" to "https://example.com/api" during build to satisfy URL constructor requirements - Add runtime replacement in start.sh to replace placeholder with actual domain endpoint - This resolves the "TypeError: Failed to construct 'URL': Invalid URL" error in the frontend 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			173 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			173 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
# Build Museum server from source
 | 
						|
FROM golang:1.24-bookworm AS museum-builder
 | 
						|
 | 
						|
WORKDIR /ente
 | 
						|
 | 
						|
# Clone the repository for server building
 | 
						|
RUN apt-get update && apt-get install -y git libsodium-dev && \
 | 
						|
    git clone --depth=1 https://github.com/ente-io/ente.git . && \
 | 
						|
    apt-get clean && apt-get autoremove && \
 | 
						|
    rm -rf /var/cache/apt /var/lib/apt/lists
 | 
						|
 | 
						|
# Build the Museum server
 | 
						|
WORKDIR /ente/server
 | 
						|
RUN go mod download && \
 | 
						|
    CGO_ENABLED=1 GOOS=linux go build -a -o museum ./cmd/museum
 | 
						|
 | 
						|
FROM node:20-bookworm-slim as web-builder
 | 
						|
 | 
						|
WORKDIR /ente
 | 
						|
 | 
						|
# Clone the repository for web app building
 | 
						|
RUN apt-get update && apt-get install -y git && \
 | 
						|
    git clone --depth=1 https://github.com/ente-io/ente.git . && \
 | 
						|
    apt-get clean && apt-get autoremove && \
 | 
						|
    rm -rf /var/cache/apt /var/lib/apt/lists
 | 
						|
 | 
						|
# Will help default to yarn version 1.22.22
 | 
						|
RUN corepack enable
 | 
						|
 | 
						|
# Set environment variables for web app build
 | 
						|
# Set the API endpoint to use current origin - this will work at runtime
 | 
						|
ENV NEXT_PUBLIC_ENTE_ENDPOINT="https://example.com/api"
 | 
						|
# Add a note for clarity
 | 
						|
RUN echo "Building with placeholder NEXT_PUBLIC_ENTE_ENDPOINT, will be served by Caddy proxy at /api"
 | 
						|
 | 
						|
# Debugging the repository structure
 | 
						|
RUN find . -type d -maxdepth 3 | sort
 | 
						|
 | 
						|
# Check if web directory exists with apps subdirectory
 | 
						|
RUN mkdir -p /build/web/photos /build/web/accounts /build/web/auth /build/web/cast && \
 | 
						|
    if [ -d "web" ] && [ -d "web/apps" ]; then \
 | 
						|
        echo "Found web/apps directory, building web apps"; \
 | 
						|
        cd web && \
 | 
						|
        yarn cache clean && \
 | 
						|
        yarn install --network-timeout 1000000000 && \
 | 
						|
        yarn build:photos && \
 | 
						|
        yarn build:accounts && \
 | 
						|
        yarn build:auth && \
 | 
						|
        yarn build:cast && \
 | 
						|
        if [ -d "apps/photos/out" ]; then \
 | 
						|
            cp -r apps/photos/out/* /build/web/photos/; \
 | 
						|
        fi && \
 | 
						|
        if [ -d "apps/accounts/out" ]; then \
 | 
						|
            cp -r apps/accounts/out/* /build/web/accounts/; \
 | 
						|
        fi && \
 | 
						|
        if [ -d "apps/auth/out" ]; then \
 | 
						|
            cp -r apps/auth/out/* /build/web/auth/; \
 | 
						|
        fi && \
 | 
						|
        if [ -d "apps/cast/out" ]; then \
 | 
						|
            cp -r apps/cast/out/* /build/web/cast/; \
 | 
						|
        fi; \
 | 
						|
    elif [ -d "web" ]; then \
 | 
						|
        echo "Found web directory, looking for alternative structure"; \
 | 
						|
        find web -type d | grep -v node_modules | sort; \
 | 
						|
        if [ -d "web/photos" ]; then \
 | 
						|
            echo "Building photos app"; \
 | 
						|
            cd web/photos && yarn install && yarn build && \
 | 
						|
            if [ -d "out" ]; then cp -r out/* /build/web/photos/; fi; \
 | 
						|
        fi; \
 | 
						|
        if [ -d "web/accounts" ]; then \
 | 
						|
            echo "Building accounts app"; \
 | 
						|
            cd web/accounts && yarn install && yarn build && \
 | 
						|
            if [ -d "out" ]; then cp -r out/* /build/web/accounts/; fi; \
 | 
						|
        fi; \
 | 
						|
        if [ -d "web/auth" ]; then \
 | 
						|
            echo "Building auth app"; \
 | 
						|
            cd web/auth && yarn install && yarn build && \
 | 
						|
            if [ -d "out" ]; then cp -r out/* /build/web/auth/; fi; \
 | 
						|
        fi; \
 | 
						|
        if [ -d "web/cast" ]; then \
 | 
						|
            echo "Building cast app"; \
 | 
						|
            cd web/cast && yarn install && yarn build && \
 | 
						|
            if [ -d "out" ]; then cp -r out/* /build/web/cast/; fi; \
 | 
						|
        fi; \
 | 
						|
    else \
 | 
						|
        echo "Web directory not found, creating placeholder web pages"; \
 | 
						|
        # Create placeholder HTML files for each app \
 | 
						|
        mkdir -p /build/web/photos /build/web/accounts /build/web/auth /build/web/cast; \
 | 
						|
        echo "<html><body><h1>Ente Photos</h1><p>Web app not available. Please check the build logs.</p></body></html>" > /build/web/photos/index.html; \
 | 
						|
        echo "<html><body><h1>Ente Accounts</h1><p>Web app not available. Please check the build logs.</p></body></html>" > /build/web/accounts/index.html; \
 | 
						|
        echo "<html><body><h1>Ente Auth</h1><p>Web app not available. Please check the build logs.</p></body></html>" > /build/web/auth/index.html; \
 | 
						|
        echo "<html><body><h1>Ente Cast</h1><p>Web app not available. Please check the build logs.</p></body></html>" > /build/web/cast/index.html; \
 | 
						|
    fi
 | 
						|
 | 
						|
FROM cloudron/base:5.0.0@sha256:04fd70dbd8ad6149c19de39e35718e024417c3e01dc9c6637eaf4a41ec4e596c
 | 
						|
 | 
						|
# Install necessary packages and Caddy webserver
 | 
						|
RUN apt-get update && \
 | 
						|
    apt-get install -y curl git nodejs npm libsodium23 libsodium-dev pkg-config postgresql-client && \
 | 
						|
    npm install -g yarn serve && \
 | 
						|
    # Install Caddy for web server
 | 
						|
    apt-get install -y debian-keyring debian-archive-keyring apt-transport-https && \
 | 
						|
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \
 | 
						|
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list && \
 | 
						|
    apt-get update && \
 | 
						|
    apt-get install -y caddy && \
 | 
						|
    apt-get clean && apt-get autoremove && \
 | 
						|
    rm -rf /var/cache/apt /var/lib/apt/lists
 | 
						|
 | 
						|
# Install Go 1.24.1
 | 
						|
RUN curl -L https://go.dev/dl/go1.24.1.linux-amd64.tar.gz -o go.tar.gz && \
 | 
						|
    rm -rf /usr/local/go && \
 | 
						|
    tar -C /usr/local -xzf go.tar.gz && \
 | 
						|
    rm go.tar.gz && \
 | 
						|
    ln -sf /usr/local/go/bin/go /usr/local/bin/go && \
 | 
						|
    ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
 | 
						|
 | 
						|
# Set up directory structure
 | 
						|
RUN mkdir -p /app/code /app/data/config /app/data/caddy /app/web
 | 
						|
 | 
						|
WORKDIR /app/code
 | 
						|
 | 
						|
# Clone the ente repository during build (for the Museum server)
 | 
						|
RUN git clone --depth=1 https://github.com/ente-io/ente.git . && \
 | 
						|
    sed -i 's/go 1.23/go 1.24.1/' server/go.mod && \
 | 
						|
    mkdir -p /app/data/go && \
 | 
						|
    cp -r server/go.mod server/go.sum /app/data/go/ && \
 | 
						|
    chmod 777 /app/data/go/go.mod /app/data/go/go.sum
 | 
						|
 | 
						|
# Pre-download Go dependencies
 | 
						|
RUN cd server && \
 | 
						|
    export GOMODCACHE="/app/data/go/pkg/mod" && \
 | 
						|
    export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod" && \
 | 
						|
    export GOTOOLCHAIN=local && \
 | 
						|
    export GO111MODULE=on && \
 | 
						|
    export GOSUMDB=off && \
 | 
						|
    mkdir -p /app/data/go/pkg/mod && \
 | 
						|
    chmod -R 777 /app/data/go && \
 | 
						|
    go mod download
 | 
						|
 | 
						|
# Set Go environment variables
 | 
						|
ENV GOTOOLCHAIN=local
 | 
						|
ENV GO111MODULE=on
 | 
						|
ENV GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod"
 | 
						|
ENV PATH="/usr/local/go/bin:${PATH}"
 | 
						|
ENV GOSUMDB=off
 | 
						|
ENV GOMODCACHE="/app/data/go/pkg/mod"
 | 
						|
 | 
						|
# Copy the web app built files from the first stage
 | 
						|
COPY --from=web-builder /build/web/photos /app/web/photos
 | 
						|
COPY --from=web-builder /build/web/accounts /app/web/accounts
 | 
						|
COPY --from=web-builder /build/web/auth /app/web/auth
 | 
						|
COPY --from=web-builder /build/web/cast /app/web/cast
 | 
						|
 | 
						|
# Copy Museum server binary from builder stage to app directory (not data volume)
 | 
						|
RUN mkdir -p /app/museum-bin
 | 
						|
COPY --from=museum-builder /ente/server/museum /app/museum-bin/museum
 | 
						|
RUN chmod +x /app/museum-bin/museum
 | 
						|
 | 
						|
# Copy configuration and startup scripts
 | 
						|
ADD start.sh /app/pkg/
 | 
						|
ADD config.template.yaml /app/pkg/
 | 
						|
 | 
						|
# Set proper permissions
 | 
						|
RUN chmod +x /app/pkg/start.sh
 | 
						|
 | 
						|
# Expose the web port (Cloudron expects port 3080)
 | 
						|
EXPOSE 3080
 | 
						|
# Also expose API port
 | 
						|
EXPOSE 8080
 | 
						|
 | 
						|
# Start the application
 | 
						|
CMD ["/app/pkg/start.sh"]  |