mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-13 00:13:33 +08:00
- 移除对 npm/npx/corepack 的直接 COPY,改为拷贝 node_modules 后重建符号链接 - COPY 会解引用符号链接,导致脚本内相对路径 require 解析失败
56 lines
1.8 KiB
Docker
56 lines
1.8 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
ARG GO_IMAGE=golang:1.25-bookworm
|
|
ARG NODE_IMAGE=node:20-bookworm
|
|
|
|
FROM ${NODE_IMAGE} AS node
|
|
|
|
FROM ${GO_IMAGE}
|
|
|
|
ARG WEBKIT_API=4.0
|
|
ARG WAILS_VERSION=v2.11.0
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV PATH=/go/bin:/usr/local/go/bin:${PATH}
|
|
|
|
# Debian's /etc/profile resets PATH in login shells (bash -l), dropping the Go
|
|
# toolchain; restore it via profile.d which is sourced after that reset.
|
|
RUN printf 'export PATH=/go/bin:/usr/local/go/bin:$PATH\n' > /etc/profile.d/10-gonavi-build-env.sh
|
|
|
|
# Copy only Node.js runtime assets so the Go toolchain from the base image
|
|
# stays intact for smoke tests and interactive build shells.
|
|
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
|
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
|
|
|
|
# npm/npx/corepack are symlinks in the node image; COPY dereferences them into
|
|
# standalone scripts whose relative requires break, so recreate the symlinks.
|
|
RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
|
|
&& ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
|
|
&& ln -sf ../lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
bash \
|
|
build-essential \
|
|
ca-certificates \
|
|
curl \
|
|
file \
|
|
git \
|
|
make \
|
|
pkg-config \
|
|
python3 \
|
|
unzip \
|
|
zip \
|
|
libgtk-3-dev \
|
|
&& if [ "${WEBKIT_API}" = "4.1" ]; then \
|
|
apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev libsoup-3.0-dev; \
|
|
else \
|
|
apt-get install -y --no-install-recommends libwebkit2gtk-4.0-dev; \
|
|
fi \
|
|
&& go install github.com/wailsapp/wails/v2/cmd/wails@${WAILS_VERSION} \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /workspace
|
|
|
|
CMD ["bash"]
|