Skip to content

Commit

Permalink
fix docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaz9 committed Jan 28, 2024
1 parent f38d0db commit 5eefe1f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 126 deletions.
21 changes: 7 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM base AS repo
FROM base AS build
COPY . .

FROM repo AS prod
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM repo AS build
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

FROM base
COPY --from=prod ./apps/cms/package.json /app/package.json
COPY --from=prod ./apps/cms/node_modules /app/node_modules
COPY --from=prod ./apps/cms/snapshot.yaml /app/snapshot.yaml
COPY --from=prod ./apps/cms/startup.sh /app/startup.sh
COPY --from=build ./apps/cms/extensions /app/extensions
WORKDIR /app
ENTRYPOINT ["startup.sh"]
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
CMD node cli.js bootstrap && node cli.js database migrate:latest && node cli.js schema apply --yes ./snapshot.yaml && node cli.js start
13 changes: 8 additions & 5 deletions apps/cms/scripts/entries.extensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from "node:path"
import { API_EXTENSION_TYPES, APP_SHARED_DEPS } from "@directus/extensions"
import { API_SHARED_DEPS } from "./externals"
import { API_EXTENSION_TYPES, API_SHARED_DEPS, APP_SHARED_DEPS } from "@directus/extensions"
import { API_PLUGINS, APP_PLUGINS } from "./plugins"
import { getBundlesEntries, getExtensionsBaseFolder } from "./utils"

Expand All @@ -12,16 +11,20 @@ export function getExtensionsEntries() {
const extensionsEntries = entries.map((entry) => {
const name = path.basename(path.dirname(entry.path))
const isApiExtension = (API_EXTENSION_TYPES as readonly string[]).includes(entry.type)
const format = isApiExtension ? "cjs" : "es"
const exports = isApiExtension ? "default" : undefined
const extension = format === "cjs" ? "cjs" : "mjs"
const file = path.resolve(`${folder}/${entry.type}s/${name}/${entry.output}.${extension}`)

return {
type: entry.type,
name,
rollupOptions: {
input: entry.path,
output: {
file: path.resolve(`${folder}/${entry.type}s/${name}/${entry.output}.js`),
format: isApiExtension ? "cjs" : "es",
exports: isApiExtension ? "default" : undefined,
file,
format,
exports,
},
external: isApiExtension ? API_SHARED_DEPS : APP_SHARED_DEPS,
plugins: isApiExtension ? API_PLUGINS : APP_PLUGINS,
Expand Down
10 changes: 3 additions & 7 deletions apps/cms/scripts/entries.migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import { getBundlesEntries, getMigrationsFolder } from "./utils"
import type { RollupOptions } from "rollup"

export function getMigrationsEntries() {
const entries = getBundlesEntries().filter(
(entry) => entry.type === "migrations",
)
const migrationsPaths = entries.flatMap((entry) =>
glob.sync(`${entry.path}/*.ts`),
)
const entries = getBundlesEntries().filter((entry) => entry.type === "migrations")
const migrationsPaths = entries.flatMap((entry) => glob.sync(`${entry.path}/*.ts`))
const folder = getMigrationsFolder()
const migrationsEntries = migrationsPaths.map((input) => {
const type = "migrations"
Expand All @@ -24,7 +20,7 @@ export function getMigrationsEntries() {
rollupOptions: {
input,
output: {
file: `${folder}/${name}.js`,
file: `${folder}/${name}.cjs`,
format: "cjs",
exports: "default",
},
Expand Down
5 changes: 0 additions & 5 deletions apps/cms/startup.sh

This file was deleted.

95 changes: 0 additions & 95 deletions pnpm-lock.yaml

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

0 comments on commit 5eefe1f

Please sign in to comment.