docker run test

This commit is contained in:
brianling 2024-04-12 22:07:50 +08:00
parent e93ed4f945
commit 32772117fe
5 changed files with 63 additions and 0 deletions

1
.env.docker Normal file
View File

@ -0,0 +1 @@
DATABASE_URL="postgresql://pjob:pjob@db:5432/pjob?schema=public"

20
docker-compose.yaml Normal file
View File

@ -0,0 +1,20 @@
version: "3.8"
services:
pjob:
build: ./pjob/
restart: always
ports:
- 80:3000
depends_on:
- db
db:
image: postgres
restart: always
volumes:
- /etc/localtime:/etc/localtime
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
environment:
- POSTGRES_USER=pjob
- POSTGRES_DB=pjob
- POSTGRES_PASSWORD=pjob

5
dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM node
WORKDIR /
COPY . /www/
CMD node /www/server/index.mjs
EXPOSE 3000

31
init.sql Normal file
View File

@ -0,0 +1,31 @@
-- CreateTable
CREATE TABLE "Data" (
"id" SERIAL NOT NULL,
"desc" VARCHAR NOT NULL DEFAULT '',
"img" VARCHAR NOT NULL DEFAULT '/Pjob.jpb',
"time" VARCHAR NOT NULL DEFAULT '',
"pay" INTEGER NOT NULL DEFAULT 1,
CONSTRAINT "Data_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Job" (
"id" SERIAL NOT NULL,
"name" VARCHAR NOT NULL,
"worktime" VARCHAR NOT NULL,
"createTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updateTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"pin" BOOLEAN NOT NULL DEFAULT true,
"dataId" INTEGER,
"place" VARCHAR NOT NULL DEFAULT 'in',
"area" VARCHAR NOT NULL DEFAULT 'in',
CONSTRAINT "Job_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Job_dataId_key" ON "Job"("dataId");
-- AddForeignKey
ALTER TABLE "Job" ADD CONSTRAINT "Job_dataId_fkey" FOREIGN KEY ("dataId") REFERENCES "Data"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

6
run Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
yarn
yarn build
cp dockerfile ./output/
cp .env.docker ./output/server/.env
docker-compose up -d