Compare commits

...

7 Commits

Author SHA1 Message Date
44b2a581ca move from deadbeef.codes to code.stevenpolley.net
All checks were successful
continuous-integration/drone Build is passing
2024-06-28 03:46:31 -06:00
389026c9e7 update to go 1.20
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-10 12:23:56 -06:00
373077e01d go mod init
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
2021-03-23 19:12:00 -06:00
12264fc1d3 add maintainer to Dockerfile
All checks were successful
continuous-integration/drone/push Build is passing
2020-10-04 21:08:55 +00:00
2a01483028 Update readme and docker-compose example
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-19 20:27:05 -06:00
2dbc274043 Merge branch 'master' of https://deadbeef.codes/steven/deadbeef.codes-publicfileserver
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-11 13:16:54 -06:00
8319643753 Remove fmt package 2020-04-04 18:39:26 -06:00
6 changed files with 51 additions and 5 deletions

View File

@ -3,7 +3,7 @@ name: default
workspace:
base: /go
path: src/deadbeef.codes/steven/deadbeef.codes-publicfileserver
path: src/code.stevenpolley.net/steven/deadbeef.codes-publicfileserver
steps:
- name: build
@ -20,5 +20,5 @@ steps:
- name: publish
image: plugins/docker
settings:
repo: registry.deadbeef.codes/deadbeef.codes-publicfileserver
repo: registry.stevenpolley.net/deadbeef.codes-publicfileserver

View File

@ -1,4 +1,5 @@
FROM scratch
LABEL maintainer="himself@stevenpolley.net"
COPY deadbeef.codes-publicfileserver /
EXPOSE 8080:8080
ENTRYPOINT ["/deadbeef.codes-publicfileserver"]

View File

@ -6,9 +6,52 @@ Serves files to the public, static content to any files in ./public
This is meant to be a spot for non-changing content, to host files to allow me to share with others. In most cases it'll be best practice to keep project-related files within the project directory and serve public static content from a webserver within that project.
### Prerequisites
1. First, install [Go](https://golang.org/dl/).
2. Then, install [Docker](https://docs.docker.com/engine/install/ubuntu/) - see left menu for other distibutions.
3. Finally, install [docker-compose](sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose)
### Build Application
```shell
go build -a -ldflags '-w'
```
You may need to log out and back in afterwards to ensure the "go" command is set in your PATH environment variable, otherwise it may say it's an invalid command.
### Build Container
Disclaimer! If you use this, youll need to build the container yourself. I have a CICD pipeline setup, but my registry is used for my internal infrastructure only and is not publicly available.
Because this is a staticly linked binary with no external runtime dependancies, the container literally only contains the binary file, keeping it clean and low in size (6.3MB). I never did understand why people include operating systems in containers.
```shell
docker build -t publicfileserver:latest .
```
### Example docker-compose.yml
```yaml
version: '3.7'
services:
publicfileserver:
image: publicfileserver:latest
restart: always
ports:
- 8080:8080
volumes:
- /data/public:/public
```
In this example, data stored on your host disk /data/public would be served
## Usage
```shell
git clone https://deadbeef.codes/steven/deadbeef.codes-publicfileserver.git
docker build -t publicfileserver:latest .
docker-compose up -d
```

View File

@ -2,7 +2,7 @@ version: '3.7'
services:
publicfileserver:
image: registry.deadbeef.codes/deadbeef.codes-publicfileserver:latest
image: publicfileserver:latest
restart: always
ports:
- 8080:8080

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module deadbeef.codes/steven/deadbeef.codes-publicfileserver
go 1.20

View File

@ -1,7 +1,6 @@
package main
import (
"fmt"
"log"
"net/http"
"os"
@ -19,5 +18,5 @@ func main() {
log.Println("started public fileserver on 8080")
<-stop
fmt.Println("Shutting server down...")
log.Println("Shutting server down...")
}