feat: add docker installation/setup
This commit is contained in:
parent
cd467d26d0
commit
7bd098e589
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@ -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"]
|
25
README.md
25
README.md
@ -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
|
note: this is a project made for learning purposes, you should use other more mature projects if running in production
|
||||||
|
|
||||||
## running:
|
## table of contents
|
||||||
- edit consts in `main.go` to match your needs. (for example, on server, change `$url` so that the response will be nicely formatted)
|
- [running abyss](#running)
|
||||||
|
- [installing with docker](#docker)
|
||||||
|
- [installing manually](#manual)
|
||||||
|
- [todo list](#todo)
|
||||||
|
|
||||||
- to run it, either build with `go build -o abyss && ./abyss` or run it directly with:
|
## running:
|
||||||
|
- 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
|
```bash
|
||||||
go run ./main.go
|
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` or run it directly with:
|
||||||
|
```bash
|
||||||
|
URL="your-domain" go run ./main.go
|
||||||
```
|
```
|
||||||
|
|
||||||
- then, simply upload your files with curl:
|
- then, simply upload your files with curl:
|
||||||
@ -17,6 +32,6 @@ curl -X POST -F "file=@/path/to/file" http://localhost:8080/upload # default url
|
|||||||
```
|
```
|
||||||
## todo:
|
## todo:
|
||||||
- [x] add upload of logs funcionality (like 0x0.st)
|
- [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 db for tracking of file names
|
||||||
- [ ] add file browser (like file://)
|
- [ ] add file browser (like file://)
|
||||||
|
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
paste:
|
||||||
|
environment:
|
||||||
|
URL: "localhost:58080"
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "58080:8080"
|
9
main.go
9
main.go
@ -10,11 +10,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
url = "localhost"
|
|
||||||
port = ":8080"
|
port = ":8080"
|
||||||
filesDir = "./files"
|
filesDir = "./files"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var url string = os.Getenv("URL")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/upload", uploadHandler)
|
http.HandleFunc("/upload", uploadHandler)
|
||||||
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(filesDir))))
|
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(filesDir))))
|
||||||
@ -54,5 +55,9 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Error copying the file", http.StatusInternalServerError)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user