-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove postgres & use a single docker container
- Loading branch information
1 parent
e2b3e6a
commit 388ac39
Showing
18 changed files
with
350 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
backend/dist/ | ||
backend/node_modules/ | ||
|
||
frontend/node_modules/ | ||
frontend/.next/ | ||
frontend/dist/ | ||
|
||
**/.git/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM node:18-alpine AS frontend-builder | ||
WORKDIR /opt/app | ||
COPY frontend/package.json frontend/package-lock.json ./ | ||
RUN npm ci | ||
COPY ./frontend . | ||
RUN npm run build | ||
|
||
FROM node:18 AS backend-builder | ||
WORKDIR /opt/app | ||
COPY backend/package.json backend/package-lock.json ./ | ||
RUN npm ci | ||
COPY ./backend . | ||
RUN npx prisma generate | ||
RUN npm run build | ||
|
||
|
||
|
||
|
||
|
||
FROM node:18 AS runner | ||
WORKDIR /opt/app/frontend | ||
ENV NODE_ENV=production | ||
COPY --from=frontend-builder /opt/app/next.config.js . | ||
COPY --from=frontend-builder /opt/app/public ./public | ||
COPY --from=frontend-builder /opt/app/.next ./.next | ||
COPY --from=frontend-builder /opt/app/node_modules ./node_modules | ||
|
||
WORKDIR /opt/app/backend | ||
COPY --from=backend-builder /opt/app/node_modules ./node_modules | ||
COPY --from=backend-builder /opt/app/dist ./dist | ||
COPY --from=backend-builder /opt/app/prisma ./prisma | ||
COPY --from=backend-builder /opt/app/package.json ./ | ||
WORKDIR /opt/app | ||
|
||
RUN npm i -g dotenv-cli | ||
|
||
EXPOSE 3000 | ||
CMD cd frontend && dotenv -e .env.development node_modules/.bin/next start & cd backend && npm run prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
node_modules/ | ||
/frontend/node_modules/ | ||
dist/ | ||
.git/ |
75 changes: 0 additions & 75 deletions
75
backend/prisma/migrations/20221006161700_inital/migration.sql
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
backend/prisma/migrations/20221011172612_init/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"password" TEXT NOT NULL, | ||
"firstName" TEXT, | ||
"lastName" TEXT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "RefreshToken" ( | ||
"token" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"expiresAt" DATETIME NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Share" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"uploadLocked" BOOLEAN NOT NULL DEFAULT false, | ||
"isZipReady" BOOLEAN NOT NULL DEFAULT false, | ||
"views" INTEGER NOT NULL DEFAULT 0, | ||
"expiration" DATETIME NOT NULL, | ||
"creatorId" TEXT NOT NULL, | ||
CONSTRAINT "Share_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "File" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"name" TEXT NOT NULL, | ||
"size" TEXT NOT NULL, | ||
"shareId" TEXT NOT NULL, | ||
CONSTRAINT "File_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ShareSecurity" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"password" TEXT, | ||
"maxViews" INTEGER, | ||
"shareId" TEXT, | ||
CONSTRAINT "ShareSecurity_shareId_fkey" FOREIGN KEY ("shareId") REFERENCES "Share" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "ShareSecurity_shareId_key" ON "ShareSecurity"("shareId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" | ||
provider = "sqlite" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This will be your database, it must exist because Docker can't mount the volume if it doesn't exist. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,16 @@ | ||
version: '3.8' | ||
services: | ||
db: | ||
image: postgres:14.1-alpine | ||
restart: unless-stopped | ||
environment: | ||
- POSTGRES_USER=${DB_USER} | ||
- POSTGRES_PASSWORD=${DB_PASSWORD} | ||
- POSTGRES_DB=pingvin-share | ||
volumes: | ||
- pingvin-share-db:/var/lib/postgresql/data | ||
backend: | ||
image: stonith404/pingvin-share-backend | ||
pingvin-share: | ||
image: stonith404/pingvin-share | ||
restart: unless-stopped | ||
ports: | ||
- 3000:3000 | ||
environment: | ||
- POSTGRES_USER=${DB_USER} | ||
- POSTGRES_PASSWORD=${DB_PASSWORD} | ||
- DB_HOST=${DB_HOST} | ||
- DB_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/pingvin-share?schema=public | ||
- APP_URL=${APP_URL} | ||
- SHOW_HOME_PAGE=${SHOW_HOME_PAGE} | ||
- ALLOW_REGISTRATION=${ALLOW_REGISTRATION} | ||
- MAX_FILE_SIZE=${MAX_FILE_SIZE} | ||
- JWT_SECRET=${JWT_SECRET} | ||
depends_on: | ||
- db | ||
volumes: | ||
- "./uploads:/usr/src/app/uploads" | ||
frontend: | ||
restart: unless-stopped | ||
ports: | ||
- '3000:3000' | ||
image: stonith404/pingvin-share-frontend | ||
environment: | ||
- SHOW_HOME_PAGE=${SHOW_HOME_PAGE} | ||
- ALLOW_REGISTRATION=${ALLOW_REGISTRATION} | ||
- MAX_FILE_SIZE=${MAX_FILE_SIZE} | ||
- BACKEND_URL=${BACKEND_URL} | ||
depends_on: | ||
- backend | ||
|
||
|
||
volumes: | ||
pingvin-share-db: | ||
- "${PWD}/data/uploads:/opt/app/backend/uploads" | ||
- "${PWD}/data/pingvin-share.db:/opt/app/backend/prisma/pingvin-share.db" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.