Add support for pnpm as a webapp build tool. #767
@ -26,6 +26,8 @@ RUN \
|
|||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||||
# Install semver
|
# Install semver
|
||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
||||||
|
# Install pnpm
|
||||||
|
&& su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \
|
||||||
&& npm cache clean --force > /dev/null 2>&1
|
&& npm cache clean --force > /dev/null 2>&1
|
||||||
|
|
||||||
# [Optional] Uncomment this section to install additional OS packages.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
@ -35,6 +37,9 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|||||||
# [Optional] Uncomment if you want to install more global node modules
|
# [Optional] Uncomment if you want to install more global node modules
|
||||||
# RUN su node -c "npm install -g <your-package-list-here>"
|
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||||
|
|
||||||
|
# We do this to get a yq binary from the published container, for the correct architecture we're building here
|
||||||
|
COPY --from=docker.io/mikefarah/yq:latest /usr/bin/yq /usr/local/bin/yq
|
||||||
|
|
||||||
# Expose port for http
|
# Expose port for http
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
@ -10,10 +10,12 @@ TRG_DIR="${3:-.next-r}"
|
|||||||
|
|
||||||
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
||||||
if [ -z "$CERC_BUILD_TOOL" ]; then
|
if [ -z "$CERC_BUILD_TOOL" ]; then
|
||||||
if [ -f "yarn.lock" ]; then
|
if [ -f "pnpm-lock.yaml" ]; then
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=pnpm
|
||||||
else
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
|
else
|
||||||
|
CERC_BUILD_TOOL=npm
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -9,7 +9,9 @@ CERC_MIN_NEXTVER=13.4.2
|
|||||||
CERC_NEXT_VERSION="${CERC_NEXT_VERSION:-keep}"
|
CERC_NEXT_VERSION="${CERC_NEXT_VERSION:-keep}"
|
||||||
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
||||||
if [ -z "$CERC_BUILD_TOOL" ]; then
|
if [ -z "$CERC_BUILD_TOOL" ]; then
|
||||||
if [ -f "yarn.lock" ]; then
|
if [ -f "pnpm-lock.yaml" ]; then
|
||||||
|
CERC_BUILD_TOOL=pnpm
|
||||||
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
|
@ -16,7 +16,9 @@ trap ctrl_c INT
|
|||||||
|
|
||||||
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
||||||
if [ -z "$CERC_BUILD_TOOL" ]; then
|
if [ -z "$CERC_BUILD_TOOL" ]; then
|
||||||
if [ -f "yarn.lock" ] && [ ! -f "package-lock.json" ]; then
|
if [ -f "pnpm-lock.yaml" ]; then
|
||||||
|
CERC_BUILD_TOOL=pnpm
|
||||||
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
|
@ -24,6 +24,10 @@ RUN \
|
|||||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||||
# Install eslint
|
# Install eslint
|
||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||||
|
# Install semver
|
||||||
|
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
||||||
|
# Install pnpm
|
||||||
|
&& su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \
|
||||||
&& npm cache clean --force > /dev/null 2>&1
|
&& npm cache clean --force > /dev/null 2>&1
|
||||||
|
|
||||||
# [Optional] Uncomment this section to install additional OS packages.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
FROM cerc/webapp-base:local as builder
|
FROM cerc/webapp-base:local as builder
|
||||||
|
|
||||||
ARG CERC_BUILD_TOOL
|
ARG CERC_BUILD_TOOL
|
||||||
|
ARG CERC_BUILD_OUTPUT_DIR
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN rm -rf node_modules build .next*
|
RUN rm -rf node_modules build dist .next*
|
||||||
RUN /scripts/build-app.sh /app build /data
|
RUN /scripts/build-app.sh /app /data
|
||||||
|
|
||||||
FROM cerc/webapp-base:local
|
FROM cerc/webapp-base:local
|
||||||
COPY --from=builder /data /data
|
COPY --from=builder /data /data
|
||||||
|
@ -7,9 +7,10 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
||||||
|
CERC_BUILD_OUTPUT_DIR="${CERC_BUILD_OUTPUT_DIR}"
|
||||||
|
|
||||||
WORK_DIR="${1:-/app}"
|
WORK_DIR="${1:-/app}"
|
||||||
OUTPUT_DIR="${2:-build}"
|
DEST_DIR="${2:-/data}"
|
||||||
DEST_DIR="${3:-/data}"
|
|
||||||
|
|
||||||
if [ -f "${WORK_DIR}/build-webapp.sh" ]; then
|
if [ -f "${WORK_DIR}/build-webapp.sh" ]; then
|
||||||
echo "Building webapp with ${WORK_DIR}/build-webapp.sh ..."
|
echo "Building webapp with ${WORK_DIR}/build-webapp.sh ..."
|
||||||
@ -22,7 +23,9 @@ elif [ -f "${WORK_DIR}/package.json" ]; then
|
|||||||
cd "${WORK_DIR}" || exit 1
|
cd "${WORK_DIR}" || exit 1
|
||||||
|
|
||||||
if [ -z "$CERC_BUILD_TOOL" ]; then
|
if [ -z "$CERC_BUILD_TOOL" ]; then
|
||||||
if [ -f "yarn.lock" ]; then
|
if [ -f "pnpm-lock.yaml" ]; then
|
||||||
|
CERC_BUILD_TOOL=pnpm
|
||||||
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
@ -33,7 +36,17 @@ elif [ -f "${WORK_DIR}/package.json" ]; then
|
|||||||
$CERC_BUILD_TOOL build || exit 1
|
$CERC_BUILD_TOOL build || exit 1
|
||||||
|
|
||||||
rm -rf "${DEST_DIR}"
|
rm -rf "${DEST_DIR}"
|
||||||
mv "${WORK_DIR}/${OUTPUT_DIR}" "${DEST_DIR}"
|
if [ -z "${CERC_BUILD_OUTPUT_DIR}" ]; then
|
||||||
|
if [ -d "${WORK_DIR}/dist" ]; then
|
||||||
|
CERC_BUILD_OUTPUT_DIR="${WORK_DIR}/dist"
|
||||||
|
elif [ -d "${WORK_DIR}/build" ]; then
|
||||||
|
CERC_BUILD_OUTPUT_DIR="${WORK_DIR}/build"
|
||||||
|
else
|
||||||
|
echo "ERROR: Unable to locate build output. Set with --extra-build-args \"--build-arg CERC_BUILD_OUTPUT_DIR=path\"" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
mv "${CERC_BUILD_OUTPUT_DIR}" "${DEST_DIR}"
|
||||||
else
|
else
|
||||||
echo "Copying static app ..."
|
echo "Copying static app ..."
|
||||||
mv "${WORK_DIR}" "${DEST_DIR}"
|
mv "${WORK_DIR}" "${DEST_DIR}"
|
||||||
|
Loading…
Reference in New Issue
Block a user