Skip to content

Commit

Permalink
feat: Auto migrate with docker hosting (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD authored Dec 9, 2024
1 parent f7f75c5 commit 2c6b761
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-app-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
build-and-push:
needs: check-changes
if: needs.check-changes.outputs.src == 'true'
if: needs.check-changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-lp-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
build-and-push:
needs: check-changes
if: needs.check-changes.outputs.src == 'true'
if: needs.check-changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
4 changes: 0 additions & 4 deletions apps/base/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export default defineNuxtConfig({
provider: 'iconify'
},

nitro: {
preset: process.env.NITRO_PRESET || 'bun',
},

colorMode: {
preference: 'dark',
fallback: 'dark'
Expand Down
20 changes: 17 additions & 3 deletions apps/shelve/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ WORKDIR /app

COPY package.json ./
COPY bun.lockb ./

COPY apps/shelve/package.json ./apps/shelve/package.json
COPY apps/shelve/entrypoint.sh ./entrypoint.sh

COPY . .

Expand All @@ -22,14 +22,28 @@ RUN bun install
RUN bun run build:app

# Stage 2: Final Stage
FROM oven/bun:latest
FROM oven/bun:latest AS final

WORKDIR /app

COPY --from=build /app/apps/shelve/.output .output
COPY --from=build /app/apps/shelve/package.json ./package.json
COPY --from=build /app/entrypoint.sh ./entrypoint.sh
COPY --from=build /app/apps/shelve/server/database/schema.ts ./server/database/schema.ts
COPY --from=build /app/apps/shelve/server/database/column.helpers.ts ./server/database/column.helpers.ts
COPY --from=build /app/apps/shelve/drizzle.config.ts ./drizzle.config.ts

RUN rm -rf .output/server/node_modules
RUN rm -rf .output/server/package.json

RUN bun install --production

RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Make the entrypoint script executable
RUN chmod +x /app/entrypoint.sh

EXPOSE 3000

CMD ["bun", "run", ".output/server/index.mjs"]
# Set the entrypoint
ENTRYPOINT ["/app/entrypoint.sh"]
7 changes: 7 additions & 0 deletions apps/shelve/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo "Running database migrations..."
bun run db:push

echo "Starting the Shelve application..."
exec bun run .output/server/index.mjs
4 changes: 2 additions & 2 deletions apps/shelve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@iconify-json/heroicons": "1.2.1",
"@iconify-json/lucide": "1.2.18",
"@iconify-json/simple-icons": "1.2.14",
"@nuxt/devtools": "1.6.3",
"@nuxt/image": "1.8.1",
"@nuxt/ui": "3.0.0-alpha.9",
"@shelve/utils": "*",
"@shelve/types": "*",
"@vueuse/core": "11.3.0",
"@vueuse/nuxt": "11.3.0",
"drizzle-kit": "0.29.1",
Expand All @@ -40,7 +40,7 @@
"zod": "3.23.8"
},
"devDependencies": {
"@shelve/types": "*",
"@nuxt/devtools": "1.6.3",
"@types/pg": "8.11.10",
"typescript": "5.7.2"
}
Expand Down

0 comments on commit 2c6b761

Please sign in to comment.