chore: add prisma migration, fly deploy files
This commit is contained in:
parent
f02bf26ec4
commit
dffaaa8acc
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
||||||
57
Dockerfile
Normal file
57
Dockerfile
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
# base node image
|
||||||
|
FROM node:16-bullseye-slim as base
|
||||||
|
|
||||||
|
# Install openssl for Prisma
|
||||||
|
RUN apt-get update && apt-get install -y openssl
|
||||||
|
|
||||||
|
# set for base and all that inherit from it
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Install all node_modules, including dev dependencies
|
||||||
|
FROM base as deps
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ADD package.json package-lock.json ./
|
||||||
|
RUN npm install --production=false
|
||||||
|
|
||||||
|
# Setup production node_modules
|
||||||
|
FROM base as production-deps
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=deps /app/node_modules /app/node_modules
|
||||||
|
ADD package.json package-lock.json ./
|
||||||
|
RUN npm prune --production
|
||||||
|
|
||||||
|
# Build the app
|
||||||
|
FROM base as build
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=deps /app/node_modules /app/node_modules
|
||||||
|
|
||||||
|
ADD prisma .
|
||||||
|
RUN npx prisma generate
|
||||||
|
|
||||||
|
ADD . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Finally, build the production image with minimal footprint
|
||||||
|
FROM base
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=production-deps /app/node_modules /app/node_modules
|
||||||
|
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
|
||||||
|
COPY --from=build /app/build /app/build
|
||||||
|
COPY --from=build /app/public /app/public
|
||||||
|
ADD . .
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start"]
|
||||||
11
fly.toml
11
fly.toml
|
|
@ -7,10 +7,17 @@ kill_timeout = 5
|
||||||
processes = []
|
processes = []
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
|
DATABASE_URL = "file:/data/sqlite.db"
|
||||||
|
PORT = "8080"
|
||||||
|
NODE_ENV = "production"
|
||||||
|
|
||||||
[experimental]
|
[experimental]
|
||||||
allowed_public_ports = []
|
cmd = "start_with_migrations.sh"
|
||||||
auto_rollback = true
|
entrypoint = "sh"
|
||||||
|
|
||||||
|
[[mounts]]
|
||||||
|
destination = "/data"
|
||||||
|
source = "data"
|
||||||
|
|
||||||
[[services]]
|
[[services]]
|
||||||
http_checks = []
|
http_checks = []
|
||||||
|
|
|
||||||
32
prisma/migrations/20220211120752_init/migration.sql
Normal file
32
prisma/migrations/20220211120752_init/migration.sql
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Team" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"icon" TEXT NOT NULL,
|
||||||
|
"description" TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "User" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"username" TEXT NOT NULL,
|
||||||
|
"icon" TEXT NOT NULL,
|
||||||
|
"passwordHash" TEXT NOT NULL,
|
||||||
|
"teamId" TEXT NOT NULL,
|
||||||
|
CONSTRAINT "User_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Expense" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
"description" TEXT NOT NULL,
|
||||||
|
"amount" REAL NOT NULL,
|
||||||
|
CONSTRAINT "Expense_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (i.e. Git)
|
||||||
|
provider = "sqlite"
|
||||||
5
start_with_migrations.sh
Normal file
5
start_with_migrations.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
npx prisma migrate deploy
|
||||||
|
npm run start
|
||||||
Loading…
Reference in a new issue