Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typos, win compatibility, and other small fixes #426

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WORKDIR /app

COPY . /app/

RUN chmod +x /app/scripts/runtime/*.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so as windows might loose the executable permission (discussed on discord). It is also done in the workers/Dockerfile so it's not that alien.


FROM backend_build AS static_files
ENV HASHID_FIELD_SALT='' \
Expand Down
2 changes: 1 addition & 1 deletion packages/infra/infra-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.3.0",
"type": "commonjs",
"scripts": {
"bootstrap": "cdk -a 'ts-node --project tsconfig.lib.json -r tsconfig-paths/register src/bootstrap.ts' deploy sb-bootstrap",
"bootstrap": "cdk -a \"ts-node --project tsconfig.lib.json -r tsconfig-paths/register src/bootstrap.ts\" deploy sb-bootstrap",
"deploy:global": "cdk deploy *GlobalStack && cdk deploy *UsEastResourcesStack",
"diff:global": "cdk diff *GlobalStack && cdk diff *UsEastResourcesStack",
"deploy:main": "cdk deploy *MainStack",
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/cli/src/lib/secretsEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const runSecretsEditor = async ({
'compose',
'run',
'--rm',
'-entrypoint /bin/bash',
'--entrypoint /bin/bash',
'ssm-editor',
`/scripts/run.sh`,
serviceName,
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/ssm-editor/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

FULL_SERVICE_NAME="env-${PROJECT_NAME}-${ENV_STAGE}-$2";
FULL_SERVICE_NAME="env-${PROJECT_NAME}-${ENV_STAGE}-$1";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is breaking the ssm-editor by placing the script name instead of the given service name. It leads to setting the invalid path in the SSM Parameter Store, for example: /env-sbtest-qa-/scripts/run.sh/test

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, I had a different experience and was only able to get the right paths on the SSM parameter store with $1. But some user in discord checked out my branch and had the opposite issue and had to revert to $2. So please leave it as $2 for now and when I test the deploy again I can look further into the issue.

CHAMBER_KMS_KEY_ALIAS="${PROJECT_NAME}-${ENV_STAGE}-main"

CHAMBER_KMS_KEY_ALIAS="${CHAMBER_KMS_KEY_ALIAS}" /bin/chamber export "${FULL_SERVICE_NAME}" \
Expand Down
3 changes: 2 additions & 1 deletion packages/workers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ COPY $SRC_CORE_PATH/package.json $DEST_CORE_PATH/
COPY $SRC_WORKERS_PATH/package.json $DEST_WORKERS_PATH/
COPY tsconfig* $APP_PATH/
COPY $SRC_CLI_PATH $DEST_CLI_PATH/
RUN pnpm install --include-workspace-root --frozen-lockfile --filter=workers... --filter=cli...

COPY nx.json tsconfig* jest* babel* .eslintrc* .prettier* .eslintrc* $APP_PATH/
COPY $SRC_CORE_PATH $DEST_CORE_PATH/
COPY $SRC_WORKERS_PATH $DEST_WORKERS_PATH/
RUN chmod +x $DEST_WORKERS_PATH/scripts/*.sh

RUN pnpm install --include-workspace-root --frozen-lockfile --filter=workers... --filter=cli...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the reason of changing the order of commands? Basically in this way it will install all pnpm deps on every source code change (it will not use cache for this) and we should avoid this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in my experience, if I don't move it, it builds successfully but it has the wrong modules and can not find the module serverless. I thought it was because COPY $SRC_WORKERS_PATH $DEST_WORKERS_PATH/ overwrites the node_modules, but that's false because it's in .dockerignore. Regarding the cache, yeah it's bad from a docker pov but I belive it gets cached by nx instead and the docker build command doesn't get triggered. Which also means you also need to pnpm nx clear-cache in between tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce right now.

  1. Revert position
  2. pnpm nx clear-cache
  3. pnpm nx run workers:compose-build-image
  4. pnpm saas up
  5. docker logs saas_{PROJECT_NAME}-workers-1
S C:\Users\me\saas_remote> docker logs saas_remote-workers-1

> nx run workers:serve

Local trigger server listening at http://0.0.0.0:3005
stdout:
> workers@2.3.0 sls /app/packages/workers
> sls "invoke" "local" "-f" "SynchronizeContentfulContent" "-d" "{\"source\":\"backend.contentfulSync\",\"detail-type\":\"complete\",\"detail\":{\"id\":\"d76db14f253e4586a016f878cb75a396\",\"type\":\"complete\"}}"
stderr: node:internal/modules/cjs/loader:1080
  throw err;
  ^
Error: Cannot find module '/app/packages/workers/node_modules/serverless/bin/serverless.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
Node.js v18.17.1
stdout:  ELIFECYCLE  Command failed with exit code 1.
child process exited with code 1


ENV PYTHONPATH=/pkgs/__pypackages__/3.9/lib \
PATH=$PATH:/pkgs/__pypackages__/3.9/bin

Expand Down