Spaces:
Paused
Paused
| # --- Stage 1: Build remotemoe --- | |
| FROM golang:1.21-alpine AS builder | |
| # Install git | |
| RUN apk add --no-cache git | |
| WORKDIR /app | |
| # Copy dependency files and download | |
| COPY go.mod go.sum ./ | |
| RUN go mod download | |
| # Copy source and build | |
| COPY . . | |
| # Build statically | |
| RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o remotemoe main.go | |
| # --- Stage 2: Runtime --- | |
| FROM alpine:latest | |
| # Install sslh (multiplexer) and ca-certificates | |
| RUN apk add --no-cache sslh ca-certificates | |
| # Create a non-root user with ID 1000 | |
| RUN adduser -D -u 1000 appuser | |
| WORKDIR /home/appuser | |
| # Copy the binary | |
| COPY --from=builder /app/remotemoe . | |
| # Create a start script | |
| RUN echo "#!/bin/sh" > start.sh && \ | |
| echo "echo 'Starting remotemoe...'" >> start.sh && \ | |
| echo "./remotemoe --ssh-addr :2222 --http-addr :8080 &" >> start.sh && \ | |
| echo "echo 'Waiting for remotemoe to initialize...'" >> start.sh && \ | |
| echo "sleep 2" >> start.sh && \ | |
| echo "echo 'Starting sslh on port 7860...'" >> start.sh && \ | |
| echo "exec sslh -f -v -p 0.0.0.0:7860 --ssh 127.0.0.1:2222 --http 127.0.0.1:8080" >> start.sh && \ | |
| chmod +x start.sh | |
| # Fix permissions so the non-root user can write SSH keys and logs | |
| RUN chown -R appuser:appuser /home/appuser | |
| # Switch to non-root user | |
| USER appuser | |
| # Expose the HF App Port | |
| EXPOSE 7860 | |
| # Run the script | |
| CMD ["./start.sh"] |