构建 cloudreve 捐赠版docker 镜像

这篇博客详细介绍了如何构建Cloudreve捐赠版的Docker镜像,包括下载捐赠版源码,修改Dockerfile,使用IDEA或命令行构建镜像,服务器上配置docker-compose.yml,设置数据库和离线下载,以及最终的运行步骤。
摘要由CSDN通过智能技术生成

一. 下载捐赠版源码修改dockerFile

PS: dockerFile当前将key.bin也就是捐赠版密钥添加到了镜像中,实际上可以不加,此时和应该将
dockerFile中的 --- "ADD key_20230114.bin ./" 此行删除,并在随后的 `docker-compose.yml` 中加入key的映射
FROM golang:1.18-alpine as cloudreve_builder

# install dependencies and build tools
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    && apk update \
    && apk add --no-cache wget curl git yarn build-base gcc abuild binutils binutils-doc gcc-doc zip \
    && yarn config set registry https://mirrors.cloud.tencent.com/npm/ \
    && yarn config get registry \
    && yarn config set "strict-ssl" false -g \
    && go env -w GOPROXY=https://goproxy.cn

WORKDIR /cloudreve_builder
COPY . .

# build frontend
WORKDIR /cloudreve_builder/assets
# Disable sourcemap in production envitonment
ENV GENERATE_SOURCEMAP false
# Disable new OpenSSL to prevent 0308010C:digital envelope routines::unsupported
ENV NODE_OPTIONS --openssl-legacy-provider

RUN yarn install --network-timeout 600000
RUN yarn run build

# build backend
WORKDIR /cloudreve_builder
RUN zip -r - assets/build >assets.zip \
    && go build -a -o cloudreve


# build final image
FROM alpine:latest

WORKDIR /cloudreve

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    && apk update && apk add --no-cache tzdata

# we using the `Asia/Shanghai` timezone by default, you can do modification at your will
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone

COPY --from=cloudreve_builder /cloudreve_builder/cloudreve ./
ADD key_20230114.bin ./
# prepare permissions and aria2 dir
RUN chmod +x ./cloudreve  \
    && ls -l ./ \
    && mkdir -p /data/aria2  \
    && chmod -R 766 /data/aria2

EXPOSE 5212
VOLUME ["/cloudreve/uploads", "/cloudreve/avatar", "/data"]

ENTRYPOINT ["./cloudreve"]

二. 构建镜像

这里我用的是IDEA插件工具 当然你也可以选择使用 build 命令构建镜像并指定 tag

docker build [OPTIONS] PATH | URL | -

IDEA构建(前提是配置好ssh连接到远程服务器)

  1. 点击左上角 运行-编辑dockerFile
  2. 编辑镜像tag
  3. 运行

在这里插入图片描述
在这里插入图片描述

三. 在服务器上创建 docker-compose.yml

此处有一点非常重要

- ./key.bin:/cloudreve/key.bin 为构建容器时使用的 key (官网下载)
如果你没有在第一步镜像中添加key,那么这一步必须,请将key上传到 docker-compose.yml 同目录

version: "3.8"
services:
  cloudreve:
    container_name: cloudreve
    image: cloudreve:tuanpro
    restart: unless-stopped
    privileged: true
    ports:
      - "5212:5212"
    volumes:
      - temp_data:/data
      - ./cloudreve/uploads:/cloudreve/uploads
      - ./cloudreve/conf.ini:/cloudreve/conf.ini
      - ./key.bin:/cloudreve/key.bin
      - ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db
      - ./cloudreve/avatar:/cloudreve/avatar
      - /mnt:/localVol
    depends_on:
      - aria2
    links:
      - aria2
  aria2:
    container_name: aria2
    image: p3terx/aria2-pro
    restart
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值