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

Add support for environment variable placeholders in hot-reloading paths #10857

Merged
merged 2 commits into from
May 22, 2024

Conversation

dfangl
Copy link
Member

@dfangl dfangl commented May 21, 2024

Motivation

When specifying a path for hot-reloading, we require an absolute path on the host, as it is expected for docker bind mounts.
However, this has an important limitation: Templates with a path defined or Cloudpods cannot be easily shared between systems where the code location differs.

For example, a checked out repository with the code at /home/user1/shared-repository/src could be checked out at /home/user2/repositories/shared-repository/src at another users machine.

To enable sharing of templates and cloudpods with hot-reloading paths between different machines without modification, this PR will add the option to use environment variables expansion within the hot-reloading paths. A hot-reloading path like $HOST_DIR/src can now be used in the templates or cloud pods, if an environment variable is set in each LocalStack instance using that path, with the concrete absolute path part as its value.

This variable could be defined relative to the docker compose project, for example, using a template like this:

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
    environment:
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=${DEBUG:-0}
      - HOST_DIR=${PWD}
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

Changes

  • The S3Key for a hot-reloading path now accepts placeholders for environment variables using $KEY or ${KEY}

@dfangl dfangl added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label May 21, 2024
@dfangl dfangl self-assigned this May 21, 2024
Copy link

github-actions bot commented May 21, 2024

LocalStack Community integration with Pro

    2 files      2 suites   1h 39m 30s ⏱️
2 983 tests 2 677 ✅ 306 💤 0 ❌
2 985 runs  2 677 ✅ 308 💤 0 ❌

Results for commit 141ea8a.

♻️ This comment has been updated with latest results.

Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

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

Great flexible idea giving full control to the user @dfangl 💡

Can we add an example to the Hot Reloading docs?

This solution enables a workaround for the CloudPod/Persistence bug #9974
@giograno Do you think this solution is sufficient to resolve #9974?

@dfangl dfangl merged commit d50eec0 into master May 22, 2024
30 checks passed
@dfangl dfangl deleted the lambda/hot-reloading-placeholders branch May 22, 2024 14:50
@giograno
Copy link
Member

This solution enables a workaround for the CloudPod/Persistence bug #9974 @giograno Do you think this solution is sufficient to resolve #9974?

That's a great solution 💯 To me, it solves #9974. I am updating the docs!

@joe4dev
Copy link
Member

joe4dev commented May 28, 2024

This solution enables a workaround for the CloudPod/Persistence bug #9974 @giograno Do you think this solution is sufficient to resolve #9974?

That's a great solution 💯 To me, it solves #9974. I am updating the docs!

Great, thank you @giograno. Can you link to the updated docs and close #9974?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants