deadbeef.codes-publicfilese.../README.md

58 lines
2.1 KiB
Markdown
Raw Normal View History

2019-11-02 17:46:28 +00:00
[![Build Status](https://drone.deadbeef.codes/api/badges/steven/deadbeef.codes-publicfileserver/status.svg)](https://drone.deadbeef.codes/steven/deadbeef.codes-publicfileserver)
2019-01-06 03:03:34 +00:00
# deadbeef.codes-publicfileserver
2019-11-02 17:46:28 +00:00
Serves files to the public, static content to any files in ./public
2019-01-07 00:29:28 +00:00
2019-06-15 18:32:51 +00:00
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.
2019-01-06 03:12:27 +00:00
### 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
2019-01-06 03:12:27 +00:00
## Usage
```shell
git clone https://deadbeef.codes/steven/deadbeef.codes-publicfileserver.git
docker build -t publicfileserver:latest .
2019-01-06 03:12:27 +00:00
docker-compose up -d
```