From 158a96c6f79a79254bb2888c3d42c53772405324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Djk=C3=A1=C5=A5o?= Date: Tue, 14 May 2024 21:00:06 +0200 Subject: [PATCH] saleor/apps didn't build again --- .dockerignore | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.toml | 43 ++++++++++++++++++++++--------------------- README.md | 4 +++- apps.Dockerfile | 26 +++++++++++++++----------- changes.sh | 20 ++++++++++++++------ 5 files changed, 103 insertions(+), 39 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a88ad85 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,49 @@ +# dependencies +node_modules +.pnp +.pnp.js + +# testing +coverage + +# next.js +.next/ +out/ +build + +# misc +.DS_Store +*.pem +.idea/ + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +.env + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# turbo +.turbo + +.saleor-app-auth.json +coverage/ +apps/**/generated +.eslintcache + +.sentryclirc + +.vscode/ +.cspellcache + +*.tsbuildinfo + +# bruno +cloud.bru diff --git a/Makefile.toml b/Makefile.toml index 2e669dd..f9146d2 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -36,7 +36,7 @@ dependencies = [ "build-abandoned-checkouts", "build-stripe", "build-klarna", - "build-authorize-net", + # "build-authorize-net", "build-avatax", "build-cms-v2", "build-crm", @@ -87,79 +87,79 @@ done workspace = false extend = "build-arg-app" private = false -env = { "APP" = "avatax" } +env = { "APP_NAME" = "app-avatax", "APP_DIR" = "avatax" } [tasks.build-cms-v2] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "cms-v2" } +env = { "APP_NAME" = "cms-v2", "APP_DIR" = "cms-v2" } [tasks.build-crm] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "crm" } +env = { "APP_NAME" = "crm", "APP_DIR" = "crm" } [tasks.build-data-importer] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "data-importer" } +env = { "APP_NAME" = "data-importer", "APP_DIR" = "data-importer" } [tasks.build-emails-and-messages] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "emails-and-messages" } +env = { "APP_NAME" = "emails-and-messages", "APP_DIR" = "emails-and-messages" } [tasks.build-invoices] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "invoices" } +env = { "APP_NAME" = "invoices", "APP_DIR" = "invoices" } [tasks.build-klaviyo] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "klaviyo" } +env = { "APP_NAME" = "klaviyo", "APP_DIR" = "klaviyo" } [tasks.build-products-feed] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "products-feed" } +env = { "APP_NAME" = "products-feed", "APP_DIR" = "products-feed" } [tasks.build-search] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "search" } +env = { "APP_NAME" = "search", "APP_DIR" = "search" } [tasks.build-segment] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "segment" } +env = { "APP_NAME" = "segment", "APP_DIR" = "segment" } [tasks.build-slack] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "slack" } +env = { "APP_NAME" = "slack", "APP_DIR" = "slack" } [tasks.build-smtp] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "smtp" } +env = { "APP_NAME" = "smtp", "APP_DIR" = "smtp" } [tasks.build-taxjar] workspace = false extend = "build-arg-app" private = false -env = { "APP" = "taxjar" } +env = { "APP_NAME" = "app-taxjar", "APP_DIR" = "taxjar" } ## DEPRECATED APPS: @@ -196,18 +196,19 @@ private = true script = ''' cd all_apps/apps -cd ./apps/${APP} +cd ./apps/${APP_DIR} VERSION=$(npm pkg get version --workspaces=false | tr -d '"') cd ../../ -docker build . --build-arg TARGET_APP="${APP}" \ - --build-arg SERVICE="saleor-app-${APP}" \ - --build-arg TITLE="djkato/saleor-app-${APP}" \ - --build-arg DESC="Saleor app for ${APP}" \ - --build-arg URL="https://github.com/saleor/saleor-app-${APP}" \ +docker build . --build-arg APP_NAME="${APP_NAME}" \ + --build-arg APP_DIR="${APP_DIR}" \ + --build-arg SERVICE="saleor-app-${APP_NAME}" \ + --build-arg TITLE="djkato/saleor-app-${APP_NAME}" \ + --build-arg DESC="Saleor app for ${APP_NAME}" \ + --build-arg URL="https://github.com/saleor/saleor-app-${APP_NAME}" \ --build-arg SOURCE="https://github.com/djkato/saleor-dockerize-all-apps" \ --build-arg AUTHORS="Saleor , Djkáťo " \ - -t ${CONTAINER_PUSH_URL}/saleor-app-${APP}:${VERSION} + -t ${CONTAINER_PUSH_URL}/saleor-app-${APP_NAME}:${VERSION} ''' [tasks.build-arg-old-app] diff --git a/README.md b/README.md index 079ab8c..a06773f 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ Current apps in repo: - saelor/abandoned-checkouts - saelor/payment-stripe - saelor/payment-klarna -- saelor/payment-authorize.net +- saelor/payment-authorize.net¹ + +¹ - doesn't build yet :( ## How to use - `./changes.sh` - applies git patches and batch edits via rust to add RedisAPL to all apps, and allow them to build via other tweaks. diff --git a/apps.Dockerfile b/apps.Dockerfile index 662158d..740de02 100644 --- a/apps.Dockerfile +++ b/apps.Dockerfile @@ -8,15 +8,18 @@ WORKDIR /app RUN npm i -g turbo pnpm COPY . . -ARG TARGET_APP +ARG APP_DIR +ARG APP_NAME # Generate a partial monorepo with a pruned lockfile for a target workspace. -RUN turbo prune "app-$TARGET_APP" --docker +RUN turbo prune "$APP_NAME" --docker # Assuming "TARGET_APP" is the name entered in the project's package.json: { name: "TARGET_APP" } # Add lockfile and package.json's of isolated subworkspace FROM base AS installer -ARG TARGET_APP +ARG APP_DIR +ARG APP_NAME + RUN apk add --no-cache libc6-compat RUN apk update WORKDIR /app @@ -29,12 +32,13 @@ RUN pnpm i # Build the project COPY --from=builder /app/out/full/ . -RUN turbo run build --filter="app-$TARGET_APP"... +RUN turbo run build --filter="$APP_NAME"... FROM base AS runner -ARG TARGET_APP +ARG APP_DIR +ARG APP_NAME WORKDIR /app # Don't run production as root @@ -42,21 +46,21 @@ RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs USER nextjs -COPY --from=installer /app/apps/$TARGET_APP/next.config.js . -COPY --from=installer /app/apps/$TARGET_APP/package.json . +COPY --from=installer /app/apps/$APP_DIR/next.config.js . +COPY --from=installer /app/apps/$APP_DIR/package.json . # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=installer --chown=nextjs:nodejs /app/apps/$TARGET_APP/.next/standalone ./ -COPY --from=installer --chown=nextjs:nodejs /app/apps/$TARGET_APP/.next/static ./apps/$TARGET_APP/.next/static -COPY --from=installer --chown=nextjs:nodejs /app/apps/$TARGET_APP/public ./apps/$TARGET_APP/public +COPY --from=installer --chown=nextjs:nodejs /app/apps/$APP_DIR/.next/standalone ./ +COPY --from=installer --chown=nextjs:nodejs /app/apps/$APP_DIR/.next/static ./apps/$APP_DIR/.next/static +COPY --from=installer --chown=nextjs:nodejs /app/apps/$APP_DIR/public ./apps/$APP_DIR/public COPY --from=installer --chown=nextjs:nodejs /app/node_modules ./node_modules # COPY --from=installer --chown=nextjs:nodejs /app/node_modules/next/dist/server/future/route-modules ./node_modules/next/dist/server/future/route-modules # COPY --from=installer --chown=nextjs:nodejs /app/node_modules/next/dist/compiled/next-server ./node_modules/next/dist/compiled/next-server # COPY --from=installer --chown=nextjs:nodejs /app/node_modules/next/dist/compiled/next-server ./node_modules/next/dist/compiled/next-server # COPY --from=installer --chown=nextjs:nodejs /app/node_modules/react/jsx-runtime ./node_modules/react/jsx-runtime -WORKDIR /app/apps/$TARGET_APP +WORKDIR /app/apps/$APP_DIR CMD node server.js ARG SERVICE ARG TITLE diff --git a/changes.sh b/changes.sh index e19b019..b9c84ea 100755 --- a/changes.sh +++ b/changes.sh @@ -5,6 +5,7 @@ REDIS_APL_PATH="$CURR_PWD/changes/snippets/redis_apl.ts" OLD_REDIS_APL_PATH="$CURR_PWD/changes/snippets/redis_apl_old_sdk.ts" APPS_DOCKERFILE_PATH="$CURR_PWD/apps.Dockerfile" OTHER_DOCKERFILE_PATH="$CURR_PWD/other.Dockerfile" +DOCKERIGNORE_PATH = "$CURR_PWD/.dockerignore" app_paths=( "apps/apps/cms-v2" @@ -50,6 +51,13 @@ cp -f ./other.Dockerfile ./all_apps/saleor-app-payment-klarna/Dockerfile cp -f ./other.Dockerfile ./all_apps/saleor-app-payment-authorize.net/Dockerfile cp -f ./other.Dockerfile ./all_apps/saleor-app-abandoned-checkouts/Dockerfile +echo "copying dockerignores..." +cp -f ./.dockerignore ./all_apps/apps/ +cp -f ./.dockerignore ./all_apps/saleor-app-payment-stripe/ +cp -f ./.dockerignore ./all_apps/saleor-app-payment-klarna/ +cp -f ./.dockerignore ./all_apps/saleor-app-payment-authorize.net/ +cp -f ./.dockerignore ./all_apps/saleor-app-abandoned-checkouts/ + echo "copying redis_apls..." for i in ${redis_apl_target_paths[*]}; do echo "copying redis_apl.ts to ./all_apps/$i" @@ -60,16 +68,16 @@ done cp -f "$OLD_REDIS_APL_PATH" "./all_apps/saleor-app-abandoned-checkouts/redis_apl.ts" # mass patch apps to use redis_apl and build in standalone -find ./all_apps/apps -name "saleor-app.ts" -exec cargo run --package modify-saleor-app -- {} \; +find ./all_apps/apps -name "saleor-app.ts" -exec cargo run --package modify-saleor-app -- {} \; >/dev/null 2>&1 echo "pached all_apps/apps/**/saleor-app.ts" -find ./all_apps/apps -name "next.config.js" -exec cargo run --package modify-next-config -- {} \; +find ./all_apps/apps -name "next.config.js" -exec cargo run --package modify-next-config -- {} \; >/dev/null 2>&1 echo "pached all_apps/apps/**/saleor-app.ts" -find ./all_apps/saleor-app-abandoned-checkouts -name "saleor-app.ts" -exec cargo run --package modify-saleor-app -- {} \; +find ./all_apps/saleor-app-abandoned-checkouts -name "saleor-app.ts" -exec cargo run --package modify-saleor-app -- {} \; >/dev/null 2>&1 echo "pached all_apps/saleor-app-abandoned-checkouts/**/saleor-app.ts" -find ./all_apps/apps/apps -name "turbo.json" -exec cargo run --package modify-turbo-json -- {} \; +find ./all_apps/apps/apps -name "turbo.json" -exec cargo run --package modify-turbo-json -- {} \; >/dev/null 2>&1 echo "pached all_apps/**/turbo.json" cd ./all_apps/ @@ -87,8 +95,8 @@ cd "$CURR_PWD" for i in ${app_paths[*]}; do cd "./all_apps/$i" - echo $(pwd) # pnpm i - pnpm i ioredis + pnpm i ioredis >/dev/null + echo "installed ioredis for $i" cd "$CURR_PWD" done