mirror of
https://github.com/lyx0/yaf.git
synced 2024-11-13 19:49:53 +01:00
Merge pull request #2 from pajlada/feat/add-dockerfile
Add Docker support
This commit is contained in:
commit
df690928a7
3 changed files with 99 additions and 0 deletions
66
.github/workflows/docker-publish.yml
vendored
Normal file
66
.github/workflows/docker-publish.yml
vendored
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
---
|
||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# Publish `master` as Docker `latest` image.
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
# Publish `v1.2.3` tags as releases.
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
# Run tests for any PRs.
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Build Docker image
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: docker build . --file Dockerfile
|
||||||
|
|
||||||
|
# Publish built Docker image to the configured registry
|
||||||
|
push:
|
||||||
|
needs: build
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Log into GitHub Container Registry
|
||||||
|
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
FROM golang:alpine as build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
RUN go build
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
COPY --from=build /app/jaf /app/jaf
|
||||||
|
WORKDIR /app
|
||||||
|
RUN mkdir -p /var/www/jaf
|
||||||
|
CMD ["./jaf"]
|
23
README.md
23
README.md
|
@ -54,6 +54,29 @@ jaf -configFile example.conf
|
||||||
```
|
```
|
||||||
Of course, you can also write a init system script to handle this for you.
|
Of course, you can also write a init system script to handle this for you.
|
||||||
|
|
||||||
|
### Running from Docker
|
||||||
|
Running it from the GitHub Container Registry
|
||||||
|
```bash
|
||||||
|
docker run \
|
||||||
|
-p 4712:4711 \
|
||||||
|
-v /path/to/your/config.conf:/app/jaf.conf \
|
||||||
|
-v /path/to/local/filedir:/var/www/jaf \
|
||||||
|
ghcr.io/leon-richardt/jaf:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Building the Docker image and running it locally
|
||||||
|
```bash
|
||||||
|
docker build -t jaf .
|
||||||
|
docker run \
|
||||||
|
-p 4712:4711 \
|
||||||
|
-v /path/to/your/config.conf:/app/jaf.conf \
|
||||||
|
-v /path/to/local/filedir:/var/www/jaf \
|
||||||
|
jaf
|
||||||
|
```
|
||||||
|
|
||||||
|
Port 4711 is the default port for the server in `example.conf`, if you've changed this in your config you'll need to change this in the `docker run` invocations above too.
|
||||||
|
The above runs forwards the jaf port from 4711 in the container to 4712 on your local system.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
You can use jaf with any application that can send POST requests (e.g. ShareX/ShareNix or just `curl`).
|
You can use jaf with any application that can send POST requests (e.g. ShareX/ShareNix or just `curl`).
|
||||||
Make sure the file you want to upload is attached as a `multipart/form-data` field named `file`.
|
Make sure the file you want to upload is attached as a `multipart/form-data` field named `file`.
|
||||||
|
|
Loading…
Reference in a new issue