mirror of https://github.com/nocodb/nocodb
Mert E
6 months ago
committed by
GitHub
8 changed files with 161 additions and 209 deletions
@ -0,0 +1,22 @@ |
|||||||
|
# Docs: https://litestream.io/reference/config/ |
||||||
|
|
||||||
|
dbs: |
||||||
|
- path: ${NC_TOOL_DIR}noco.db |
||||||
|
replicas: |
||||||
|
- type: s3 |
||||||
|
endpoint: ${LITESTREAM_S3_ENDPOINT} |
||||||
|
force-path-style: true |
||||||
|
skip-verify: ${LITESTREAM_S3_SKIP_VERIFY} |
||||||
|
bucket: ${LITESTREAM_S3_BUCKET} |
||||||
|
path: ${LITESTREAM_S3_PATH} |
||||||
|
access-key-id: ${LITESTREAM_S3_ACCESS_KEY_ID} |
||||||
|
secret-access-key: ${LITESTREAM_S3_SECRET_ACCESS_KEY} |
||||||
|
retention: ${LITESTREAM_RETENTION} |
||||||
|
retention-check-interval: ${LITESTREAM_RETENTION_CHECK_INTERVAL} |
||||||
|
snapshot-interval: ${LITESTREAM_SNAPSHOT_INTERVAL} |
||||||
|
sync-interval: ${LITESTREAM_SYNC_INTERVAL} |
||||||
|
# age: |
||||||
|
# identities: |
||||||
|
# - ${LITESTREAM_AGE_SECRET_KEY} |
||||||
|
# recipients: |
||||||
|
# - ${LITESTREAM_AGE_PUBLIC_KEY} |
@ -1,26 +1,37 @@ |
|||||||
#!/bin/sh |
#!/bin/sh |
||||||
|
|
||||||
#sleep 5 |
if [ ! -d "${NC_TOOL_DIR}" ] ; then |
||||||
|
|
||||||
if [ -n "${NC_TOOL_DIR}" ]; then |
|
||||||
mkdir -p "$NC_TOOL_DIR" |
mkdir -p "$NC_TOOL_DIR" |
||||||
fi |
fi |
||||||
|
|
||||||
if [ -n "${AWS_ACCESS_KEY_ID}" ] && [ -n "${AWS_SECRET_ACCESS_KEY}" ] && [ -n "${AWS_BUCKET}" ] && [ -n "${AWS_BUCKET_PATH}" ]; then |
use_litestream() { |
||||||
|
[ -z "${NC_DB}" ] \ |
||||||
|
&& [ -z "${NC_DB_JSON}" ] \ |
||||||
|
&& [ -z "${NC_DB_JSON_FILE}" ] \ |
||||||
|
&& [ -z "${DATABASE_URL}" ] \ |
||||||
|
&& [ -z "${DATABASE_URL_FILE}" ] \ |
||||||
|
&& [ -z "${NC_MINIMAL_DBS}" ] \ |
||||||
|
&& [ -n "${LITESTREAM_S3_ENDPOINT}" ] \ |
||||||
|
&& [ -n "${LITESTREAM_S3_BUCKET}" ] \ |
||||||
|
&& [ -n "${LITESTREAM_ACCESS_KEY_ID}" ] \ |
||||||
|
&& [ -n "${LITESTREAM_SECRET_ACCESS_KEY}" ] |
||||||
|
} |
||||||
|
|
||||||
|
if use_litestream ; then |
||||||
|
|
||||||
if [ -f "${NC_TOOL_DIR}noco.db" ] |
if [ -f "${NC_TOOL_DIR}noco.db" ] ; then |
||||||
then |
|
||||||
rm "${NC_TOOL_DIR}noco.db" |
rm "${NC_TOOL_DIR}noco.db" |
||||||
rm "${NC_TOOL_DIR}noco.db-shm" |
rm -f "${NC_TOOL_DIR}noco.db-shm" |
||||||
rm "${NC_TOOL_DIR}noco.db-wal" |
rm -f "${NC_TOOL_DIR}noco.db-wal" |
||||||
fi |
fi |
||||||
|
|
||||||
/usr/src/appEntry/litestream restore -o "${NC_TOOL_DIR}noco.db" "s3://$AWS_BUCKET/$AWS_BUCKET_PATH" |
litestream restore "${NC_TOOL_DIR}noco.db" |
||||||
if [ ! -f "${NC_TOOL_DIR}noco.db" ] |
|
||||||
then |
if [ ! -f "${NC_TOOL_DIR}noco.db" ] ; then |
||||||
touch "${NC_TOOL_DIR}noco.db" |
touch "${NC_TOOL_DIR}noco.db" |
||||||
fi |
fi |
||||||
/usr/src/appEntry/litestream replicate "${NC_TOOL_DIR}noco.db" "s3://$AWS_BUCKET/$AWS_BUCKET_PATH" & |
|
||||||
|
litestream replicate & |
||||||
fi |
fi |
||||||
|
|
||||||
node docker/main.js |
node docker/main.js |
||||||
|
@ -1,96 +0,0 @@ |
|||||||
FROM golang:alpine3.18 as lt |
|
||||||
|
|
||||||
WORKDIR /usr/src/ |
|
||||||
|
|
||||||
RUN apk add --no-cache git make musl-dev gcc |
|
||||||
|
|
||||||
# build litestream |
|
||||||
RUN git clone https://github.com/benbjohnson/litestream.git litestream |
|
||||||
RUN cd litestream ; go install ./cmd/litestream |
|
||||||
|
|
||||||
RUN cp $GOPATH/bin/litestream /usr/src/lt |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM node:18.19.1-alpine as builder |
|
||||||
WORKDIR /usr/src/app |
|
||||||
|
|
||||||
# install pnpm |
|
||||||
RUN corepack enable && corepack prepare pnpm@latest --activate |
|
||||||
|
|
||||||
# Copy application dependency manifests to the container image. |
|
||||||
COPY ./package*.json ./ |
|
||||||
COPY ./docker/main.js ./docker/main.js |
|
||||||
#COPY ./docker/start.sh /usr/src/appEntry/start.sh |
|
||||||
COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh |
|
||||||
|
|
||||||
# for pnpm to generate a flat node_modules without symlinks |
|
||||||
# so that modclean could work as expected |
|
||||||
RUN echo "node-linker=hoisted" > .npmrc |
|
||||||
|
|
||||||
# install production dependencies, |
|
||||||
# reduce node_module size with modclean & removing sqlite deps, |
|
||||||
# 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 chmod +x /usr/src/appEntry/start.sh |
|
||||||
|
|
||||||
FROM alpine:3.19 |
|
||||||
|
|
||||||
#ENV AWS_ACCESS_KEY_ID= |
|
||||||
#ENV AWS_SECRET_ACCESS_KEY= |
|
||||||
#ENV AWS_BUCKET= |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#WORKDIR /usr/src/ |
|
||||||
# |
|
||||||
## Install go lang |
|
||||||
#RUN apk add --no-cache git make musl-dev go |
|
||||||
# |
|
||||||
## Configure Go |
|
||||||
#ENV GOROOT /usr/lib/go |
|
||||||
#ENV GOPATH /go |
|
||||||
#ENV PATH /go/bin:$PATH |
|
||||||
# |
|
||||||
#RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin |
|
||||||
# |
|
||||||
## build litestream |
|
||||||
# |
|
||||||
#RUN git clone https://github.com/benbjohnson/litestream.git litestream |
|
||||||
#RUN cd litestream ; go install ./cmd/litestream |
|
||||||
|
|
||||||
|
|
||||||
# Bug fix for segfault ( Convert PT_GNU_STACK program header into PT_PAX_FLAGS ) |
|
||||||
#RUN apk --update --no-cache add paxctl \ |
|
||||||
# && paxctl -cm $(which node) |
|
||||||
|
|
||||||
WORKDIR /usr/src/app |
|
||||||
|
|
||||||
ENV NC_DOCKER 0.6 |
|
||||||
ENV PORT 8080 |
|
||||||
ENV NC_TOOL_DIR=/usr/app/data/ |
|
||||||
|
|
||||||
|
|
||||||
# Copy application dependency manifests to the container image. |
|
||||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied. |
|
||||||
# Copying this separately prevents re-running npm install on every code change. |
|
||||||
#COPY ./build/ ./build/ |
|
||||||
#COPY ./docker/main.js ./docker/main.js |
|
||||||
#COPY ./package.json ./ |
|
||||||
|
|
||||||
RUN apk --update --no-cache add \ |
|
||||||
nodejs \ |
|
||||||
tar |
|
||||||
|
|
||||||
# Copy litestream binary build |
|
||||||
COPY --from=lt /usr/src/lt /usr/src/appEntry/litestream |
|
||||||
# Copy production code & main entry file |
|
||||||
COPY --from=builder /usr/src/app/ /usr/src/app/ |
|
||||||
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/ |
|
||||||
|
|
||||||
|
|
||||||
# Run the web service on container startup. |
|
||||||
#CMD [ "node", "docker/index.js" ] |
|
||||||
ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"] |
|
Loading…
Reference in new issue