Dockerfile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. FROM library/node:16-alpine as frontBuilder
  2. USER root
  3. RUN mkdir -p /usr/src/app
  4. WORKDIR /usr/src/app
  5. add ./frontend/.npmrc /usr/src/app
  6. add ./frontend/package.json /usr/src/app
  7. add ./frontend/package-lock.json /usr/src/app
  8. RUN npm ci
  9. COPY ./frontend /usr/src/app
  10. RUN ls -al
  11. RUN npm run build && ls -al dist/spa
  12. FROM golang:1.17-buster AS builder
  13. ARG VERSION=0.0.10
  14. LABEL stage=gobuilder
  15. # 开始编译
  16. ENV CGO_ENABLED 1
  17. ENV GO111MODULE=on
  18. ENV GOOS linux
  19. #ENV GOPROXY https://goproxy.cn,direct
  20. # 切换工作目录
  21. WORKDIR /homelab/buildspace
  22. COPY . .
  23. # 把前端编译好的文件 copy 过来
  24. COPY --from=frontBuilder /usr/src/app/dist/spa /homelab/buildspace/frontend/dist/spa
  25. # 执行编译,-o 指定保存位置和程序编译名称
  26. RUN cd ./cmd/chinesesubfinder \
  27. && go build -ldflags="-s -w --extldflags '-static -fpic' -X main.AppVersion=${VERSION}" -o /app/chinesesubfinder
  28. # 运行时环境
  29. FROM lsiobase/ubuntu:bionic
  30. ENV TZ=Asia/Shanghai PERMS=true \
  31. PUID=1026 PGID=100
  32. RUN ln -s /root/.cache/rod/chromium-856583/chrome-linux/chrome /usr/bin/chrome && \
  33. # sed -i "s@http://archive.ubuntu.com@http://mirrors.aliyun.com@g" /etc/apt/sources.list && rm -Rf /var/lib/apt/lists/* && \
  34. apt-get update && \
  35. apt-get install --no-install-recommends -y \
  36. yasm ffmpeg \
  37. # C、C++ 支持库
  38. libgcc-6-dev libstdc++6 \
  39. # chromium dependencies
  40. libnss3 \
  41. libxss1 \
  42. libasound2 \
  43. libxtst6 \
  44. libgtk-3-0 \
  45. libgbm1 \
  46. # fonts
  47. fonts-liberation fonts-noto-color-emoji fonts-noto-cjk \
  48. # processs reaper
  49. dumb-init \
  50. # headful mode support, for example: $ xvfb-run chromium-browser --remote-debugging-port=9222
  51. xvfb \
  52. xorg gtk2-engines-pixbuf \
  53. dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable \
  54. imagemagick x11-apps \
  55. # 通用
  56. ca-certificates \
  57. wget \
  58. # cleanup
  59. && apt-get clean \
  60. && rm -rf \
  61. /tmp/* \
  62. /var/lib/apt/lists/* \
  63. /var/tmp/*
  64. COPY Docker/root/ /
  65. # 主程序
  66. COPY --from=builder /app/chinesesubfinder /app/chinesesubfinder
  67. VOLUME /config /media