temp3 / Dockerfile
motoe moto
Update Dockerfile
3126291 verified
# Use an official Ubuntu as a parent image
FROM ubuntu:20.04
# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
# Install required packages
RUN apt-get update && apt-get install -y \
git \
curl \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Install Golang
RUN curl -LO https://golang.org/dl/go1.18.10.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.18.10.linux-amd64.tar.gz && \
rm go1.18.10.linux-amd64.tar.gz
# Set up Go environment
ENV GOPATH=/go
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
# Set the working directory inside the container
WORKDIR /app
# Clone the Transfer.sh repository
RUN git clone https://github.com/dutchcoders/transfer.sh.git .
# Move to the correct directory
WORKDIR /app
# Install any needed dependencies specified in the go.mod and go.sum files
RUN /usr/local/go/bin/go mod tidy
# Build the Go app for the correct architecture
RUN GOOS=linux GOARCH=amd64 /usr/local/go/bin/go build -o transfersh ./cmd
# Set executable permissions for the binary
RUN chmod +x transfersh
# Create a Downloads directory for storage
RUN mkdir -p /app/Downloads && chmod -R 777 /app/Downloads
# Create a temp directory
RUN mkdir -p /app/temp && chmod -R 777 /app/temp
# Expose the port the app runs on
EXPOSE 8080
# Environment variables to avoid common issues
ENV PYTHONUNBUFFERED=1 \
GRADIO_ALLOW_FLAGGING=never \
GRADIO_NUM_PORTS=1 \
GRADIO_SERVER_NAME=0.0.0.0 \
SYSTEM=spaces
# Run the app
CMD ["./transfersh", "--provider", "local", "--basedir", "/app/Downloads", "--temp-path", "/app/temp"]
# Health check to ensure the container is running correctly
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/ || exit 1