-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove hardcoding from deploy config
- Loading branch information
Showing
10 changed files
with
398 additions
and
109 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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
DOMAIN=http://modes.local | ||
POSTGRES_HOST=db | ||
POSTGRES_HOST=localhost | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB=modes | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public" | ||
API_HOST=localhost | ||
API_PORT=3000 |
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,12 +1,19 @@ | ||
FROM node:20-slim | ||
FROM node:20-alpine | ||
|
||
RUN corepack enable && corepack prepare pnpm@latest --activate | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
COPY package*.json ./ | ||
COPY pnpm-lock.yaml ./ | ||
COPY nx.json ./ | ||
COPY tsconfig*.json ./ | ||
COPY eslint.config.js ./ | ||
|
||
RUN pnpm install --frozen-lockfile | ||
|
||
EXPOSE 3000 | ||
COPY apps/api ./apps/api | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["pnpm", "nx", "run", "api:serve", "--configuration=production"] |
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 |
---|---|---|
@@ -1,25 +1,40 @@ | ||
import * as trpcExpress from '@trpc/server/adapters/express'; | ||
import cors from 'cors'; | ||
import 'dotenv/config'; | ||
import express from 'express'; | ||
import { z } from 'zod'; | ||
import { prisma } from './db/client'; | ||
import { appRouter } from './trpc/root'; | ||
import { createContext } from './trpc/router'; | ||
|
||
const host = process.env.HOST ?? 'localhost'; | ||
const port = process.env.PORT ? Number(process.env.PORT) : 3000; | ||
const envSchema = z.object({ | ||
API_HOST: z.string().default('localhost'), | ||
API_PORT: z.string().transform((val) => Number(val)), | ||
DATABASE_URL: z.string().url(), | ||
}); | ||
|
||
const env = envSchema.parse(process.env); | ||
|
||
const app = express(); | ||
|
||
app.use(cors()); | ||
|
||
app.use( | ||
'/api/trpc', | ||
'/api', | ||
trpcExpress.createExpressMiddleware({ | ||
router: appRouter, | ||
createContext, | ||
}) | ||
); | ||
|
||
app.listen(port, host, () => { | ||
// TODO: logging | ||
console.log(`[ ready ] http://${host}:${port}`); | ||
}); | ||
const start = async () => { | ||
// Check if the database is connected | ||
await prisma.$connect(); | ||
|
||
app.listen(env.API_PORT, env.API_HOST, () => { | ||
// TODO: logging | ||
console.log(`[ ready ] http://${env.API_HOST}:${env.API_PORT}`); | ||
}); | ||
}; | ||
|
||
start(); |
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 |
---|---|---|
@@ -1,46 +1,54 @@ | ||
/// <reference types='vitest' /> | ||
import { defineConfig } from 'vite'; | ||
import react from '@vitejs/plugin-react-swc'; | ||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; | ||
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin'; | ||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; | ||
import react from '@vitejs/plugin-react-swc'; | ||
import { defineConfig, loadEnv } from 'vite'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default defineConfig({ | ||
root: __dirname, | ||
cacheDir: '../../node_modules/.vite/apps/web', | ||
server: { | ||
port: 4200, | ||
host: 'localhost', | ||
}, | ||
preview: { | ||
port: 4300, | ||
host: 'localhost', | ||
}, | ||
plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])], | ||
// Uncomment this if you are using workers. | ||
// worker: { | ||
// plugins: [ nxViteTsPaths() ], | ||
// }, | ||
build: { | ||
outDir: '../../dist/apps/web', | ||
emptyOutDir: true, | ||
reportCompressedSize: true, | ||
commonjsOptions: { | ||
transformMixedEsModules: true, | ||
export default defineConfig(({ mode }) => { | ||
const env = loadEnv(mode, process.cwd(), ''); | ||
const apiHost = env.API_HOST || 'localhost'; | ||
const apiPort = env.API_PORT || '3000'; | ||
|
||
return { | ||
root: __dirname, | ||
cacheDir: '../../node_modules/.vite/apps/web', | ||
server: { | ||
port: 4200, | ||
host: 'localhost', | ||
proxy: { | ||
'/api': { | ||
target: `http://${apiHost}:${apiPort}`, | ||
changeOrigin: true, | ||
}, | ||
}, | ||
}, | ||
preview: { | ||
port: 4300, | ||
host: 'localhost', | ||
}, | ||
plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])], | ||
build: { | ||
outDir: '../../dist/apps/web', | ||
emptyOutDir: true, | ||
reportCompressedSize: true, | ||
commonjsOptions: { | ||
transformMixedEsModules: true, | ||
}, | ||
}, | ||
test: { | ||
watch: false, | ||
globals: true, | ||
environment: 'jsdom', | ||
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
reporters: ['default'], | ||
coverage: { | ||
reportsDirectory: '../../coverage/apps/web', | ||
provider: 'v8', | ||
}, | ||
}, | ||
}, | ||
test: { | ||
watch: false, | ||
globals: true, | ||
environment: 'jsdom', | ||
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
reporters: ['default'], | ||
coverage: { | ||
reportsDirectory: '../../coverage/apps/web', | ||
provider: 'v8', | ||
define: { | ||
'process.env.MEDIA_URL': JSON.stringify('https://m.untu.ms'), | ||
}, | ||
}, | ||
define: { | ||
'process.env.MEDIA_URL': JSON.stringify('https://m.untu.ms'), | ||
}, | ||
}; | ||
}); |
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
Oops, something went wrong.