Move stored data to a volume

Fix the silly data wipe on re-deployment by writing the data to a
volume instead of the ephemeral container filesystem.
This commit is contained in:
Hornwitser 2025-03-05 18:42:56 +01:00
parent 6ea3567c94
commit 5cc310384e
5 changed files with 7 additions and 97 deletions

View file

@ -2,5 +2,5 @@ node_modules
.nuxt/
.output/
dist
data
env*
push-subscriptions.json

2
.gitignore vendored
View file

@ -24,4 +24,4 @@ logs
!.env.example
# Data
push-subscriptions.json
data

View file

@ -17,15 +17,15 @@ COPY . .
RUN corepack enable pnpm && pnpm run build
# Production image, copy all the files and run next
# Production image, copy all the files and run Nuxt
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/.output ./
COPY --chown=node:node schedule.json .
RUN echo '[]' > push-subscriptions.json && chown node:node push-subscriptions.json
RUN install --owner=node --group=node --directory data
VOLUME [ "/app/data" ]
USER node

View file

@ -1,90 +0,0 @@
{
"locations": [
{
"name": "House",
"id": "house",
"description": "Blue building east of the camping"
},
{
"name": "Common House",
"id": "common-house",
"description": "That big red building in the middle"
},
{
"name": "Info Desk",
"id": "info-desk",
"description": "Found at the entrance"
},
{
"name": "Camping Fireplace",
"id": "camping-fireplace",
"description": "Next to the big tree"
}
],
"events": [
{
"name": "Arcade",
"id": "arcade",
"description": "Play retro games!",
"slots": [
{
"id": "arcade-1",
"start": "2025-07-18T10:00Z",
"end": "2025-07-19T01:30Z",
"locations": ["house"]
},
{
"id": "arcade-2",
"start": "2025-07-19T10:00Z",
"end": "2025-07-20T01:00Z",
"locations": ["house"]
},
{
"id": "arcade-3",
"start": "2025-07-20T10:00Z",
"end": "2025-07-20T18:00Z",
"locations": ["house"]
}
]
},
{
"name": "Bonfire Stories",
"description": "Share your stories as we sit cosily around the bonfire.",
"id": "bonfire",
"slots": [
{
"id": "bonfire-1",
"start": "2025-07-19T20:00Z",
"end": "2025-07-20T01:00Z",
"locations": ["camping-fireplace"]
}
]
},
{
"name": "Fursuit Games",
"description": "Playful time for the suiters.",
"id": "fursuit-games",
"slots": [
{
"id": "fursuit-games-1",
"start": "2025-07-19T19:00Z",
"end": "2025-07-19T20:00Z",
"locations": ["common-house"]
}
]
},
{
"name": "Late Stragglers",
"description": "Wait a minute, why are you still here?.",
"id": "too-late",
"slots": [
{
"id": "too-late-1",
"start": "2025-07-22T20:00Z",
"end": "2025-07-23T01:00Z",
"locations": ["camping-fireplace"]
}
]
}
]
}

View file

@ -4,8 +4,8 @@ import { Schedule } from "~/shared/types/schedule";
// For this demo I'm just storing the runtime data in JSON files. When making
// this into proper application this should be replaced with an actual database.
const schedulePath = "schedule.json"
const subscriptionsPath = "push-subscriptions.json"
const schedulePath = "data/schedule.json"
const subscriptionsPath = "data/subscriptions.json"
export async function readSchedule() {
let schedule: Schedule;