Browse Source

refactor: avoid unfavorable tar -> untar in container image (#8439)

* fix: avoid undesirable tar -> untar in container image

* fix: apply shellcheck suggestions

* fix: copy production code to proper dir

---------

Co-authored-by: mertmit <mertmit99@gmail.com>
pull/8475/head
Salim B 6 months ago committed by GitHub
parent
commit
373ba0d396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      packages/nocodb/Dockerfile
  2. 4
      packages/nocodb/Dockerfile.local
  3. 16
      packages/nocodb/docker/start-litestream.sh
  4. 11
      packages/nocodb/docker/start-local.sh
  5. 9
      packages/nocodb/docker/start.sh
  6. 6
      packages/nocodb/litestream/Dockerfile

4
packages/nocodb/Dockerfile

@ -40,7 +40,7 @@ RUN echo "node-linker=hoisted" > .npmrc
# install production dependencies,
# reduce node_module size with modclean & removing sqlite deps,
# package built code into app.tar.gz & add execute permission to start.sh
# and add execute permission to start.sh
RUN pnpm install --prod --shamefully-hoist \
&& pnpm dlx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,@azure/msal-node/dist/**" --run \
&& rm -rf ./node_modules/sqlite3/deps \
@ -63,7 +63,7 @@ RUN apk --update --no-cache add \
# Copy litestream binary build
COPY --from=lt-builder /usr/src/lt /usr/src/appEntry/litestream
# Copy packaged production code & main entry file
# Copy production code & main entry file
COPY --from=builder /usr/src/app/ /usr/src/app/
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/

4
packages/nocodb/Dockerfile.local

@ -23,7 +23,7 @@ RUN echo "node-linker=hoisted" > .npmrc
# install production dependencies,
# reduce node_module size with modclean & removing sqlite deps,
# package built code into app.tar.gz & add execute permission to start.sh
# and add execute permission to start.sh
RUN pnpm uninstall nocodb-sdk
RUN pnpm install --prod --shamefully-hoist --reporter=silent \
&& pnpm dlx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,@azure/msal-node/dist/**" --run \
@ -47,7 +47,7 @@ RUN apk --update --no-cache add \
curl \
jq
# Copy packaged production code & main entry file
# Copy production code & main entry file
COPY --from=builder /usr/src/app/ /usr/src/app/
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/

16
packages/nocodb/docker/start-litestream.sh

@ -1,13 +1,12 @@
#!/bin/sh
FILE="/usr/src/app/package.json"
#sleep 5
if [ ! -z "${NC_TOOL_DIR}" ]; then
mkdir -p $NC_TOOL_DIR
if [ -n "${NC_TOOL_DIR}" ]; then
mkdir -p "$NC_TOOL_DIR"
fi
if [[ ! -z "${AWS_ACCESS_KEY_ID}" && ! -z "${AWS_SECRET_ACCESS_KEY}" && ! -z "${AWS_BUCKET}" && ! -z "${AWS_BUCKET_PATH}" ]]; then
if [ -n "${AWS_ACCESS_KEY_ID}" ] && [ -n "${AWS_SECRET_ACCESS_KEY}" ] && [ -n "${AWS_BUCKET}" ] && [ -n "${AWS_BUCKET_PATH}" ]; then
if [ -f "${NC_TOOL_DIR}noco.db" ]
then
@ -16,17 +15,12 @@ if [[ ! -z "${AWS_ACCESS_KEY_ID}" && ! -z "${AWS_SECRET_ACCESS_KEY}" && ! -z "${
rm "${NC_TOOL_DIR}noco.db-wal"
fi
/usr/src/appEntry/litestream restore -o "${NC_TOOL_DIR}noco.db" s3://$AWS_BUCKET/$AWS_BUCKET_PATH;
/usr/src/appEntry/litestream restore -o "${NC_TOOL_DIR}noco.db" "s3://$AWS_BUCKET/$AWS_BUCKET_PATH"
if [ ! -f "${NC_TOOL_DIR}noco.db" ]
then
touch "${NC_TOOL_DIR}noco.db"
fi
/usr/src/appEntry/litestream replicate "${NC_TOOL_DIR}noco.db" s3://$AWS_BUCKET/$AWS_BUCKET_PATH &
fi
if [ ! -f "$FILE" ]
then
tar -xzf /usr/src/appEntry/app.tar.gz -C /usr/src/app/
/usr/src/appEntry/litestream replicate "${NC_TOOL_DIR}noco.db" "s3://$AWS_BUCKET/$AWS_BUCKET_PATH" &
fi
node docker/main.js

11
packages/nocodb/docker/start-local.sh

@ -1,14 +1,7 @@
#!/bin/sh
FILE="/usr/src/app/package.json"
if [ ! -z "${NC_TOOL_DIR}" ]; then
mkdir -p $NC_TOOL_DIR
fi
if [ ! -f "$FILE" ]
then
tar -xzf /usr/src/appEntry/app.tar.gz -C /usr/src/app/
if [ -n "${NC_TOOL_DIR}" ]; then
mkdir -p "$NC_TOOL_DIR"
fi
node docker/index.js

9
packages/nocodb/docker/start.sh

@ -1,10 +1,3 @@
#!/bin/sh
FILE="/usr/src/app/package.json"
if [ ! -f "$FILE" ]
then
tar -xzf /usr/src/appEntry/app.tar.gz -C /usr/src/app/
fi
node docker/main.js
node docker/main.js

6
packages/nocodb/litestream/Dockerfile

@ -30,11 +30,10 @@ RUN echo "node-linker=hoisted" > .npmrc
# install production dependencies,
# reduce node_module size with modclean & removing sqlite deps,
# package built code into app.tar.gz & add execute permission to start.sh
# and add execute permission to start.sh
RUN pnpm install --prod --shamefully-hoist --reporter=silent
RUN pnpm dlx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run
RUN rm -rf ./node_modules/sqlite3/deps
RUN tar -czf ../appEntry/app.tar.gz ./*
RUN chmod +x /usr/src/appEntry/start.sh
FROM alpine:3.19
@ -87,7 +86,8 @@ RUN apk --update --no-cache add \
# Copy litestream binary build
COPY --from=lt /usr/src/lt /usr/src/appEntry/litestream
# Copy packaged production code & main entry file
# Copy production code & main entry file
COPY --from=builder /usr/src/app/ /usr/src/app/
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/

Loading…
Cancel
Save