Skip to content

Commit

Permalink
Share tsconfig through package and build rif into Docker image (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
junlarsen authored Sep 25, 2024
1 parent d94ae51 commit 9465e11
Show file tree
Hide file tree
Showing 45 changed files with 2,213 additions and 2,868 deletions.
2 changes: 1 addition & 1 deletion apps/brevduen/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM public.ecr.aws/lambda/nodejs:20 AS builder
WORKDIR /usr/app
COPY apps ./apps
COPY packages ./packages
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json turbo.json ./
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./

RUN npm i -g pnpm@9.0.4
RUN pnpm install --frozen-lockfile
Expand Down
1 change: 1 addition & 0 deletions apps/brevduen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"@types/aws-lambda": "^8.10.129",
"@types/node": "^20.12.7",
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/brevduen/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"compilerOptions": {
"jsx": "react-jsx"
},
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/config": "workspace:^",
"@dotkomonline/tsconfig": "workspace:*",
"@types/node": "^20.12.7",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": [
"next-env.d.ts",
"./**/*.ts",
Expand Down
1 change: 1 addition & 0 deletions apps/invoicification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/config": "workspace:^",
"@dotkomonline/tsconfig": "workspace:*",
"@types/node": "^20.12.7",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
Expand Down
2 changes: 1 addition & 1 deletion apps/invoicification/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": [
"next-env.d.ts",
"./**/*.ts",
Expand Down
43 changes: 43 additions & 0 deletions apps/rif/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM node:22-alpine AS base

FROM base AS builder
WORKDIR /app

RUN apk update && apk add --no-cache libc6-compat
RUN npm install -g pnpm@9.4.0 turbo@2.0.14
COPY apps ./apps
COPY packages ./packages
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
RUN turbo prune @dotkomonline/rif --docker

FROM base AS installer
WORKDIR /app

ENV DOCKER_BUILD=1

RUN npm install -g pnpm@9.4.0 turbo@2.0.14
COPY --from=builder /app/out/json .
RUN pnpm install
COPY --from=builder /app/out/full .
RUN turbo run build --filter @dotkomonline/rif

FROM base AS runner
WORKDIR /app

RUN apk add --no-cache curl

EXPOSE 3000

ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME=0.0.0.0

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer --chown=nextjs:nodejs /app/apps/rif/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/rif/.next/static ./apps/rif/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/rif/public ./apps/rif/public

CMD node apps/rif/server.js
1 change: 1 addition & 0 deletions apps/rif/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const config = {
reactStrictMode: true,
swcMinify: true,
transpilePackages: ["@dotkomonline/env", "@dotkomonline/ui"],
output: "standalone",
}

export default config
5 changes: 4 additions & 1 deletion apps/rif/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"start": "next start",
"lint": "biome check . --write",
"lint-check": "biome check .",
"type-check": "tsc --noEmit"
"type-check": "tsc --noEmit",
"docker:build": "docker build --platform linux/amd64 -t rif:latest -f Dockerfile ../..",
"docker:push:prod": "docker tag rif:latest 891459268445.dkr.ecr.eu-north-1.amazonaws.com/monoweb/prod/rif:latest && docker push 891459268445.dkr.ecr.eu-north-1.amazonaws.com/monoweb/prod/rif:latest"
},
"dependencies": {
"@dotkomonline/env": "workspace:*",
Expand Down Expand Up @@ -36,6 +38,7 @@
"@types/react-dom": "^18.2.17",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.31",
"postcss-import": "^16.1.0",
"tailwindcss": "^3.3.5",
"tslib": "^2.6.2",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion apps/rif/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": [
"next-env.d.ts",
"./**/*.ts",
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@biomejs/biome": "^1.9.2",
"@dotkomonline/config": "workspace:*",
"@dotkomonline/logger": "workspace:*",
"@dotkomonline/tsconfig": "workspace:*",
"@types/cors": "^2.8.17",
"@types/jsdom": "^21.1.6",
"@types/node": "^20.12.7",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": [
"./**/*.ts",
"./**/*.tsx",
Expand Down
6 changes: 0 additions & 6 deletions apps/wiki/next-env.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"typescript": "^5.4.5"
}
}
2 changes: 1 addition & 1 deletion packages/auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": ["./**/*.ts", "./**/*.tsx"]
}
3 changes: 2 additions & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
],
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"@radix-ui/colors": "^3.0.0",
"@tailwindcss/typography": "^0.5.10",
"postcss-import": "^15.1.0",
"postcss-import": "^16.1.0",
"postcss": "^8.4.31",
"tailwindcss-animate": "^1.0.7",
"tailwindcss-radix": "^2.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "../../tsconfig.json"
"extends": "../../packages/tsconfig/tsconfig.json"
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/types": "workspace:*",
"@dotkomonline/tsconfig": "workspace:*",
"@testcontainers/postgresql": "^10.11.0",
"@types/node": "^20.12.7",
"@vitest/ui": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": ["./**/*.ts"],
"compilerOptions": {
"types": ["vitest/globals"]
Expand Down
1 change: 1 addition & 0 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"@types/pg": "^8.10.9",
"kysely-codegen": "^0.15.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/db/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true
Expand Down
1 change: 1 addition & 0 deletions packages/emails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"@types/react": "^18.2.38",
"react-email": "^1.9.5",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/emails/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"exclude": [],
"compilerOptions": {
"baseUrl": ".",
Expand Down
1 change: 1 addition & 0 deletions packages/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"typescript": "^5.4.5"
}
}
4 changes: 2 additions & 2 deletions packages/env/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from "zod"

const environmentVariableSchema = z.string().nonempty()

export const createEnvironment = (skipValidation = false) =>
export const createEnvironment = () =>
createEnv({
clientPrefix: "NEXT_PUBLIC_",
server: {
Expand Down Expand Up @@ -71,7 +71,7 @@ export const createEnvironment = (skipValidation = false) =>

S3_BUCKET_MONOWEB: process.env.S3_BUCKET_MONOWEB,
},
skipValidation,
skipValidation: process.env.DOCKER_BUILD !== undefined,
})

export const env = createEnvironment()
2 changes: 1 addition & 1 deletion packages/env/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"include": ["./**/*.ts", "./**/*.tsx", "index.mjs"]
}
1 change: 1 addition & 0 deletions packages/gateway-edge-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"@vitest/ui": "^1.3.1",
"typescript": "^5.4.5",
"vitest": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/gateway-edge-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"exclude": [],
"include": ["./**/*.ts", "./**/*.tsx"]
}
1 change: 1 addition & 0 deletions packages/gateway-trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"@dotkomonline/types": "workspace:*",
"@vitest/ui": "^1.3.1",
"typescript": "^5.4.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/gateway-trpc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"exclude": [],
"include": ["./**/*.ts", "./**/*.tsx"]
}
3 changes: 2 additions & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"winston": "^3.13.0"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2"
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/logger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true
Expand Down
12 changes: 12 additions & 0 deletions packages/tsconfig/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@dotkomonline/tsconfig",
"version": "0.1.0",
"license": "MIT",
"type": "module",
"scripts": {
"clean": "rm -rf .turbo node_modules"
},
"exports": {
"./tsconfig.json": "./tsconfig.json"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json → packages/tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
},
"include": ["apps/", "packages/", "tools/"],
"include": ["../../apps/", "../../packages/", "../../tools/"],
"noErrorTruncation": true
}
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"typescript": "^5.4.5"
}
}
2 changes: 1 addition & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true
Expand Down
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/config": "workspace:*",
"@dotkomonline/tsconfig": "workspace:*",
"@ladle/react": "^4.0.3",
"@types/react": "^18.2.38",
"autoprefixer": "^10.4.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true,
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"@dotkomonline/tsconfig": "workspace:*",
"typescript": "^5.4.5"
}
}
2 changes: 1 addition & 1 deletion packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../packages/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true
Expand Down
Loading

0 comments on commit 9465e11

Please sign in to comment.