diff --git a/.gitignore b/.gitignore index 8b29b7a..1499f03 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ uploads bin # Other files -todo.md \ No newline at end of file +todo.md +build-docker.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 330d5ad..578c523 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,28 @@ -FROM golang:1.24 AS builder +FROM golang:1.26 AS builder WORKDIR /app -COPY go.mod go.sum ./ +# No additional dependencies, no go.sum +# COPY go.mod go.sum ./ +COPY go.mod ./ RUN go mod download -COPY . . +COPY static/ ./static/ +COPY templates/ ./templates/ +COPY *.go ./ RUN CGO_ENABLED=0 GOOS=linux go build -o curier . FROM scratch +WORKDIR / + +ENV CURIER_HOST="0.0.0.0" +ENV CURIER_PORT="39800" +ENV CURIER_STORAGE_PATH="/uploads/" + COPY --from=builder /app/curier /curier -EXPOSE 8080 +EXPOSE 39800 ENTRYPOINT ["/curier"] \ No newline at end of file diff --git a/README.md b/README.md index 239c265..a98a43e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A small Go server for sharing files across the internet. You can download the Dockerfile and build the image yourself, or simply pull it from the repo: ```bash docker pull ghcr.io/adipeterca/curier:latest -docker run -p 8080:8080 ghcr.io/adipeterca/curier:latest +docker run -p 39800:39800 ghcr.io/adipeterca/curier:latest ``` ### Linux environment @@ -26,6 +26,9 @@ You can download a precompiled binary from the [Release](https://github.com/adip ## Configuration You can configure some aspects of the service via environment variables prefixed with **CURIER_**. + +_If you're using Docker, either use a `.env` file or the `-e` argument from the `docker run` command._ + Some information will be exposed via the `/config/` endpoint for better UX. For default values, check [config.go](https://github.com/adipeterca/curier/blob/main/config.go). diff --git a/config.go b/config.go index 9b2539f..1142008 100644 --- a/config.go +++ b/config.go @@ -17,16 +17,16 @@ var templateFiles embed.FS // -- Private variables --- // Where to save the uploaded files -var storagePath = "/var/lib/curier/uploads/" +var storagePath = "uploads/" // URL base path that will prefix all download links var urlBasePath = "http://localhost" -// Network address to bind to - default 127.0.0.1 -var host = "127.0.0.1" +// Network address to bind to - default 0.0.0.0 +var host = "0.0.0.0" -// Port to listen on - default 8080 -var port = "8080" +// Port to listen on - default 39800 +var port = "39800" // --- Public variables --- //