Skip to content

Commit 5c7a9f5

Browse files
committed
fix: mount database
1 parent 63f5d52 commit 5c7a9f5

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ testing/k6/notebooks/
5959
# autogenerated api docs
6060
apps/outreach/src/content/docs/en/runtime-core-docs/
6161

62-
# mongodb
62+
# docker dbs
6363
mongo/
64+
sqlite/

apps/gateway/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM node:iron-alpine AS base
22
WORKDIR /app
33
ARG RELEASE_VERSION
4-
ENV GATEWAY_DATABASE_URL=file:/app/gateway.db
4+
ENV GATEWAY_DATABASE_URL=file:/app/sqlite/gateway.db
55
ENV PNPM_HOME="/pnpm"
66
ENV PATH="$PNPM_HOME:$PATH"
77
ENV NODE_OPTIONS="--max-old-space-size=8192"
@@ -25,12 +25,13 @@ RUN turbo run db:push --filter=@opendatacapture/gateway
2525

2626
# RUN SERVER
2727
FROM base AS runner
28-
COPY --from=installer /app/gateway.db /app/gateway.db
28+
COPY apps/gateway/scripts/run.sh run.sh
29+
COPY --from=installer /app/sqlite/gateway.db /app/gateway.tmpl.db
2930
COPY --from=installer /app/apps/gateway/dist/ /app/dist/
3031
COPY --from=installer /app/apps/gateway/public/ /app/public/
3132
COPY --from=installer /app/apps/gateway/dist/runtime/ /runtime/
3233
COPY --from=installer /app/apps/gateway/dist/prisma/client/ /.prisma/client/
3334

3435
RUN echo '{ "type": "module" }' > package.json
3536
RUN echo '{ "type": "module" }' > /runtime/package.json
36-
CMD [ "node", "./dist/main.js" ]
37+
CMD [ "./run.sh" ]

apps/gateway/scripts/run.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
DATABASE_FILE=${GATEWAY_DATABASE_URL#file:}
4+
EMPTY_DATABASE_FILE="/app/gateway.tmpl.db"
5+
6+
if [[ ! -f "$DATABASE_FILE" ]]; then
7+
cp "$EMPTY_DATABASE_FILE" "$DATABASE_FILE"
8+
fi
9+
10+
node ./dist/main.js

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: open-data-capture
22
volumes:
33
caddy_data:
4-
mongo_config:
5-
mongo_data:
64
services:
75
caddy:
86
image: caddy:2.7-alpine
@@ -66,6 +64,8 @@ services:
6664
environment:
6765
- NODE_ENV=production
6866
- GATEWAY_API_KEY
67+
volumes:
68+
- ./sqlite:/app/sqlite
6969
web:
7070
image: ghcr.io/douglasneuroinformatics/open-data-capture-web:${RELEASE_CHANNEL}
7171
build:

0 commit comments

Comments
 (0)