Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Letsmoe committed Nov 17, 2023
1 parent 8a01922 commit 097b45e
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 695 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
name: Node.js CD
name: Node.js Package

on:
push:
branches: [ main ]
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
- run: bun test

publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy using ssh
uses: appleboy/ssh-action@master
with:
host: "212.227.155.91"
username: "root"
password: "!2Zc727cI1"
port: 22
script: |
cd ~/database
git reset --hard HEAD
git clean -f -d
git pull origin main
git status
bash build.sh
- uses: actions/checkout@v2
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
# Publish to NPM
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
registry: "https://npm.pkg.github.com"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
# Keep environment variables out of version control
.env
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM postgres:latest
ENV POSTGRES_USER main
ENV POSTGRES_PASSWORD ctACGEEnNe5NHL76qXKYiAwyBht4hRKz743EDFcpzDXXtLU4QBRPZAvVdhDQgrQf
ENV POSTGRES_DB main
ENV POSTGRES_USER ${POSTGRES_DATABASE_USER}
ENV POSTGRES_PASSWORD ${POSTGRES_DATABASE_PASSWORD}
ENV POSTGRES_DB ${POSTGRES_DATABASE_NAME}

COPY scripts /docker-entrypoint-initdb.d/
COPY ./prisma/migrations/ /docker-entrypoint-initdb.d/
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

Binary file added bun.lockb
Binary file not shown.
9 changes: 9 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { PrismaClient } from "@prisma/client";

export function createContext(ctx: any): Promise<Context>;

export * from ".prisma/client/index.d";

export interface Context {
prisma: PrismaClient;
}
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
database:
build: ../database
ports:
- "5436:5432"
volumes:
- ./data:/var/lib/postgresql/data
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@continuum-ai/database",
"version": "0.0.1",
"module": "./src/index.ts",
"types": "./dist/index.d.ts",
"type": "module",
"scripts": {
"db:introspect": "dotenv -- prisma introspect",
"db:generate": "dotenv -- prisma generate"
},
"postinstall": "tsc && cp src/index.d.ts dist/index.d.ts && bunx prisma generate",
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@prisma/client": "5.6.0",
"bun-types": "latest",
"tsc": "^2.0.4"
},
"devDependencies": {
"dotenv-cli": "^4.0.0",
"prisma": "5.6.0",
"typescript": "^4.2.3"
}
}
14 changes: 14 additions & 0 deletions prisma/migrations/20231117082312_initial/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "Users" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"name" TEXT,
"password" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Users_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Users_email_key" ON "Users"("email");
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
21 changes: 21 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_DATABASE_URL")
}

model Users {
id Int @id @default(autoincrement())
email String @unique
name String?
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
9 changes: 9 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { PrismaClient } from "@prisma/client";

export function createContext(ctx: any): Promise<Context>;

export * from ".prisma/client/index.d";

export interface Context {
prisma: PrismaClient;
}
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PrismaClient } from "@prisma/client";
import { Context } from "./index.d";

const prisma = new PrismaClient();

export const createContext = async (ctx: any): Promise<Context> => {
return { ...ctx, prisma };
};
22 changes: 22 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}

0 comments on commit 097b45e

Please sign in to comment.