+
Skip to content

Add Docker Image and Corresponding Github Action #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,37 @@
name: Publish Docker image
name: Create and publish Container Images

on: push

jobs:
buildx:
build-container-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

# Required if building multi-arch images
- name: Set up QEMU
- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- id: buildx
name: Set up Docker Buildx
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
install: true

- name: Login to DockerHub
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64,linux/386
push: true
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ github.repository }}:latest
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
30 changes: 13 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
FROM golang
FROM docker.io/alpine:edge AS build
WORKDIR /dms
ADD . /dms
RUN apk add --no-cache go gcc musl-dev
RUN go mod tidy
RUN go build -trimpath -buildmode=pie -ldflags="-s -w" -o dms

RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
ffmpeg \
ffmpegthumbnailer \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
touch /root/.dms-ffprobe-cache

COPY . /go/src/github.com/anacrolix/dms/
WORKDIR /go/src/github.com/anacrolix/dms/
RUN \
go build -v .

ENTRYPOINT [ "./dms" ]
FROM docker.io/alpine:edge
COPY --from=build --chown=1000:1000 /dms/dms /dms
RUN apk add --no-cache ffmpeg ffmpegthumbnailer mailcap
USER 1000:1000
WORKDIR /dmsdir
VOLUME /dmsdir
ENTRYPOINT ["/dms"]
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ To run::

$ "$GOPATH"/bin/dms

Running DMS using Docker
========================

`dms` is distributed as Docker Image. Serve Media in `/mediadirectory` using `dms`:

.. code-block:: bash

docker pull ghcr.io/anacrolix/dms:latest
docker run -d --network host -v /mediadirectory:/dmsdir ghcr.io/anacrolix/dms:latest

Running DMS as a systemd service
=================================

Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载