Skip to content

Commit

Permalink
fix dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaz9 committed Feb 4, 2024
1 parent 5eefe1f commit cf84fec
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.git
.gitignore
.turbo
.rollup.cache
.rollup.cache
node_modules
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
FROM node:21-alpine AS base
FROM node:latest AS build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM base AS build
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
WORKDIR /apps/cms
RUN pnpm run build
RUN pnpm run build --migrationsOnly
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN pnpm install --force --frozen-lockfile
RUN pnpm run build:cms

FROM directus/directus
ENV ADMIN_EMAIL="admin@example.com"
ENV ADMIN_PASSWORD="d1r3ctu5"
COPY --from=build ./apps/cms/snapshot.yaml ./snapshot.yaml
COPY --from=build ./apps/cms/extensions ./extensions
COPY --from=build ./usr/src/app/apps/cms/snapshot.yaml ./snapshot.yaml
COPY --from=build ./usr/src/app/apps/cms/extensions ./extensions
CMD node cli.js bootstrap && node cli.js database migrate:latest && node cli.js schema apply --yes ./snapshot.yaml && node cli.js start
2 changes: 1 addition & 1 deletion apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"dev": "concurrently \"pnpm:watch\" \"pnpm:start\"",
"start": "directus start",
"build:cms": "pnpm build && pnpm build --migrationsOnly",
"build": "tsx --tsconfig tsconfig.build.json scripts/builder.ts",
"watch": "tsx --tsconfig tsconfig.build.json scripts/builder.ts --watch",
"bootstrap": "directus bootstrap",
Expand Down Expand Up @@ -46,7 +47,6 @@
"@types/express": "4.17.21",
"@vitejs/plugin-vue": "5.0.3",
"@vue/compiler-sfc": "3.4.15",
"chalk": "5.3.0",
"concurrently": "8.2.2",
"eslint-config-custom": "workspace:*",
"from": "0.1.7",
Expand Down
10 changes: 5 additions & 5 deletions apps/cms/scripts/builder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import chalk from "chalk"
import { rollup, watch } from "rollup"

import "dotenv/config"

import { gray, green, red } from "./console"
import { getExtensionsEntries } from "./entries.extensions"
import { getMigrationsEntries } from "./entries.migrations"
import { deleteFolders, getExtensionsFolders, getMigrationsFolder } from "./utils"
Expand All @@ -26,12 +26,12 @@ async function run() {
case "BUNDLE_END":
const endEntry = findEntry(data.input as string)
const endId = `${endEntry.type}:${endEntry.name}`
console.log(chalk.gray(`${endId} - `) + chalk.green("✅ Compiled succesfully"))
console.log(gray(`${endId} - `) + green("✅ Compiled succesfully"))
break
case "ERROR":
const errorEntry = findEntry(data.error.watchFiles![0]!)
const errorId = `${errorEntry.type}:${errorEntry.name}`
console.log(chalk.gray(`${errorId} - `) + chalk.red(data.error.message))
console.log(gray(`${errorId} - `) + red(data.error.message))
break
}
})
Expand All @@ -46,9 +46,9 @@ async function run() {
const output = await rollup(entry.rollupOptions)
output.write(entry.rollupOptions.output)

console.log(chalk.gray(`${id} - `) + chalk.green("✅ Compiled succesfully"))
console.log(gray(`${id} - `) + green("✅ Compiled succesfully"))
} catch (error: any) {
console.log(chalk.gray(`${id} - `) + chalk.red(error.message))
console.log(gray(`${id} - `) + red(error.message))
}
}),
)
Expand Down
5 changes: 5 additions & 0 deletions apps/cms/scripts/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const gray = (text: string) => `\x1b[90m${text}\x1b[0m`

export const green = (text: string) => `\x1b[32m${text}\x1b[0m`

export const red = (text: string) => `\x1b[31m${text}\x1b[0m`
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"packageManager": "pnpm@8.15.0",
"scripts": {
"build": "turbo run build",
"build:cms": "turbo run build:cms",
"start": "turbo run start",
"dev": "turbo run dev",
"lint": "turbo run lint",
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"ADMIN_PASSWORD"
]
},
"cms#ci-build": {
"dependsOn": ["cms#build"]
"cms#build:cms": {
"dependsOn": ["^build"]
},
"web#build": {
"dependsOn": ["^build"],
Expand Down

0 comments on commit cf84fec

Please sign in to comment.