mirror of
https://github.com/rclone/rclone.git
synced 2024-11-21 16:03:29 +01:00
build docker plugin (#5415)
This commit is contained in:
parent
daf449b5f2
commit
55153403aa
@ -32,3 +32,40 @@ jobs:
|
||||
publish: true
|
||||
dockerHubUser: ${{ secrets.DOCKER_HUB_USER }}
|
||||
dockerHubPassword: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
||||
|
||||
build_docker_volume_plugin:
|
||||
if: github.repository == 'rclone/rclone'
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
name: Build and publish docker volume plugin
|
||||
steps:
|
||||
- name: Checkout master
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set plugin parameters
|
||||
shell: bash
|
||||
run: |
|
||||
GITHUB_REF=${{ github.ref }}
|
||||
|
||||
PLUGIN_IMAGE_USER=rclone
|
||||
PLUGIN_IMAGE_NAME=docker-volume-rclone
|
||||
PLUGIN_IMAGE_TAG=${GITHUB_REF#refs/tags/}
|
||||
PLUGIN_IMAGE=${PLUGIN_IMAGE_USER}/${PLUGIN_IMAGE_NAME}:${PLUGIN_IMAGE_TAG}
|
||||
PLUGIN_IMAGE_LATEST=${PLUGIN_IMAGE_USER}/${PLUGIN_IMAGE_NAME}:latest
|
||||
|
||||
echo "PLUGIN_IMAGE_USER=${PLUGIN_IMAGE_USER}" >> $GITHUB_ENV
|
||||
echo "PLUGIN_IMAGE_NAME=${PLUGIN_IMAGE_NAME}" >> $GITHUB_ENV
|
||||
echo "PLUGIN_IMAGE_TAG=${PLUGIN_IMAGE_TAG}" >> $GITHUB_ENV
|
||||
echo "PLUGIN_IMAGE=${PLUGIN_IMAGE}" >> $GITHUB_ENV
|
||||
echo "PLUGIN_IMAGE_LATEST=${PLUGIN_IMAGE_LATEST}" >> $GITHUB_ENV
|
||||
- name: Build image
|
||||
shell: bash
|
||||
run: |
|
||||
make docker-plugin
|
||||
- name: Push image
|
||||
shell: bash
|
||||
run: |
|
||||
docker login -u ${{ secrets.DOCKER_HUB_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
|
||||
make docker-plugin-push PLUGIN_IMAGE=${PLUGIN_IMAGE}
|
||||
make docker-plugin-push PLUGIN_IMAGE=${PLUGIN_IMAGE_LATEST}
|
||||
|
33
Makefile
33
Makefile
@ -256,3 +256,36 @@ startstable:
|
||||
|
||||
winzip:
|
||||
zip -9 rclone-$(TAG).zip rclone.exe
|
||||
|
||||
# docker volume plugin
|
||||
PLUGIN_IMAGE_USER ?= rclone
|
||||
PLUGIN_IMAGE_TAG ?= latest
|
||||
PLUGIN_IMAGE_NAME ?= docker-volume-rclone
|
||||
PLUGIN_IMAGE ?= $(PLUGIN_IMAGE_USER)/$(PLUGIN_IMAGE_NAME):$(PLUGIN_IMAGE_TAG)
|
||||
|
||||
PLUGIN_BASE_IMAGE := rclone/rclone:latest
|
||||
PLUGIN_BUILD_DIR := ./build/docker-plugin
|
||||
PLUGIN_CONTRIB_DIR := ./cmd/serve/docker/contrib/plugin
|
||||
PLUGIN_CONFIG := $(PLUGIN_CONTRIB_DIR)/config.json
|
||||
PLUGIN_DOCKERFILE := $(PLUGIN_CONTRIB_DIR)/Dockerfile
|
||||
PLUGIN_CONTAINER := docker-volume-rclone-dev-$(shell date +'%Y%m%d-%H%M%S')
|
||||
|
||||
docker-plugin: docker-plugin-rootfs docker-plugin-create
|
||||
|
||||
docker-plugin-image: rclone
|
||||
docker build --no-cache --pull --build-arg BASE_IMAGE=${PLUGIN_BASE_IMAGE} -t ${PLUGIN_IMAGE} -f ${PLUGIN_DOCKERFILE} .
|
||||
|
||||
docker-plugin-rootfs: docker-plugin-image
|
||||
mkdir -p ${PLUGIN_BUILD_DIR}/rootfs
|
||||
docker create --name ${PLUGIN_CONTAINER} ${PLUGIN_IMAGE}
|
||||
docker export ${PLUGIN_CONTAINER} | tar -x -C ${PLUGIN_BUILD_DIR}/rootfs
|
||||
docker rm -vf ${PLUGIN_CONTAINER}
|
||||
cp ${PLUGIN_CONFIG} ${PLUGIN_BUILD_DIR}/config.json
|
||||
|
||||
docker-plugin-create:
|
||||
docker plugin rm -f ${PLUGIN_IMAGE} 2>/dev/null || true
|
||||
docker plugin create ${PLUGIN_IMAGE} ${PLUGIN_BUILD_DIR}
|
||||
|
||||
docker-plugin-push: docker-plugin-create
|
||||
docker plugin push ${PLUGIN_IMAGE}
|
||||
docker plugin rm ${PLUGIN_IMAGE}
|
||||
|
31
cmd/serve/docker/contrib/plugin/Dockerfile
Normal file
31
cmd/serve/docker/contrib/plugin/Dockerfile
Normal file
@ -0,0 +1,31 @@
|
||||
ARG BASE_IMAGE=rclone/rclone:latest
|
||||
ARG BUILD_PLATFORM=linux/amd64
|
||||
ARG TARGET_PLATFORM=linux/amd64
|
||||
|
||||
# temporary build image
|
||||
FROM --platform=${BUILD_PLATFORM} golang:alpine AS BUILD_ENV
|
||||
|
||||
COPY . /src
|
||||
WORKDIR /src
|
||||
|
||||
RUN apk add --no-cache make git bash && \
|
||||
CGO_ENABLED=0 \
|
||||
GOARCH=$(echo ${TARGET_PLATFORM} | cut -d '/' -f2) \
|
||||
make rclone
|
||||
|
||||
# plugin image
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
COPY --from=BUILD_ENV /src/rclone /usr/local/bin/rclone
|
||||
|
||||
RUN mkdir -p /data/config /data/cache /mnt \
|
||||
&& /usr/local/bin/rclone version
|
||||
|
||||
ENV RCLONE_CONFIG=/data/config/rclone.conf
|
||||
ENV RCLONE_CACHE_DIR=/data/cache
|
||||
ENV RCLONE_BASE_DIR=/mnt
|
||||
ENV RCLONE_VERBOSE=0
|
||||
|
||||
WORKDIR /data
|
||||
ENTRYPOINT ["/usr/local/bin/rclone"]
|
||||
CMD ["serve", "docker"]
|
66
cmd/serve/docker/contrib/plugin/config.json
Normal file
66
cmd/serve/docker/contrib/plugin/config.json
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"description": "Rclone volume plugin for Docker",
|
||||
"documentation": "https://rclone.org/",
|
||||
"interface": {
|
||||
"socket": "rclone.sock",
|
||||
"types": ["docker.volumedriver/1.0"]
|
||||
},
|
||||
"linux": {
|
||||
"capabilities": [
|
||||
"CAP_SYS_ADMIN"
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"path": "/dev/fuse"
|
||||
}
|
||||
]
|
||||
},
|
||||
"network": {
|
||||
"type": "host"
|
||||
},
|
||||
"entrypoint": ["/usr/local/bin/rclone", "serve", "docker"],
|
||||
"workdir": "/data",
|
||||
"args": {
|
||||
"name": "args",
|
||||
"value": [],
|
||||
"settable": ["value"]
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "RCLONE_VERBOSE",
|
||||
"value": "0",
|
||||
"settable": ["value"]
|
||||
},
|
||||
{
|
||||
"name": "RCLONE_CONFIG",
|
||||
"value": "/data/config/rclone.conf"
|
||||
},
|
||||
{
|
||||
"name": "RCLONE_CACHE_DIR",
|
||||
"value": "/data/cache"
|
||||
},
|
||||
{
|
||||
"name": "RCLONE_BASE_DIR",
|
||||
"value": "/mnt"
|
||||
}
|
||||
],
|
||||
"mounts": [
|
||||
{
|
||||
"name": "config",
|
||||
"source": "/var/lib/docker-plugins/rclone/config",
|
||||
"destination": "/data/config",
|
||||
"type": "bind",
|
||||
"options": ["rbind"],
|
||||
"settable": ["source"]
|
||||
},
|
||||
{
|
||||
"name": "cache",
|
||||
"source": "/var/lib/docker-plugins/rclone/cache",
|
||||
"destination": "/data/cache",
|
||||
"type": "bind",
|
||||
"options": ["rbind"],
|
||||
"settable": ["source"]
|
||||
}
|
||||
],
|
||||
"propagatedMount": "/mnt"
|
||||
}
|
Loading…
Reference in New Issue
Block a user