Skip to content

Commit

Permalink
feat: add docker installation/setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuxas committed Aug 19, 2024
1 parent cd467d2 commit 7bd098e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.23

WORKDIR /app

# COPY go.mod go.sum ./
COPY go.mod ./

RUN go mod download

COPY *.go ./

RUN CGO_ENABLED=0 GOOS=linux go build -o /abyss

CMD ["/abyss"]
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ abyss is a basic http server made for uploading files (logs, images) and then sh

note: this is a project made for learning purposes, you should use other more mature projects if running in production

## table of contents
- [running abyss](#running)
- [installing with docker](#docker)
- [installing manually](#manual)
- [todo list](#todo)

## running:
- edit consts in `main.go` to match your needs. (for example, on server, change `$url` so that the response will be nicely formatted)
- change URL env variable in to your domain. example: `URL=paste.abyss.dev`
### docker
- to run with docker, you can use either docker compose or just straight docker.
- then run the docker compose command:
```bash
docker compose up -d # might be docker-compose depending on distro
```
- dont change inside port of 8080 unless you know what you're doing

### manual

- to run it, either build with `go build -o abyss && ./abyss` or run it directly with:
- to run it, either build with `go build -o abyss` or run it directly with:
```bash
go run ./main.go
URL="your-domain" go run ./main.go
```

- then, simply upload your files with curl:
Expand All @@ -17,6 +32,6 @@ curl -X POST -F "file=@/path/to/file" http://localhost:8080/upload # default url
```
## todo:
- [x] add upload of logs funcionality (like 0x0.st)
- [ ] add docker easy setup
- [x] add docker easy setup
- [ ] add db for tracking of file names
- [ ] add file browser (like file://)
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
paste:
environment:
URL: "localhost:58080"
build: .
ports:
- "58080:8080"
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
)

const (
url = "localhost"
port = ":8080"
filesDir = "./files"
)

var url string = os.Getenv("URL")

func main() {
http.HandleFunc("/upload", uploadHandler)
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(filesDir))))
Expand Down Expand Up @@ -54,5 +55,9 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Error copying the file", http.StatusInternalServerError)
}

fmt.Fprintf(w, "http://%s%s/%d\n", url, port, time)
if url == "" {
fmt.Fprintf(w, "http://localhost%s/%d\n", port, time)
} else {
fmt.Fprintf(w, "http://%s/%d\n", url, time)
}
}

0 comments on commit 7bd098e

Please sign in to comment.