Dockerfile 2.0 KB

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