skip to Main Content

In order to speed up my integration tests execution, I’d like to have a custom localstack pro container with some aws resources already created.

Basically I start a docker compose file with the below configuration, run some awslocal and tflocal commands, then stop the container and run docker commit, but when I run the saved container the changes I made are not there.

I was able to use this same strategy for the same purpose with postgres(start a postgres container, run some migrations with liquibase, run docker commit), but in that case I had to use the PGDATA variable to have the changes persisted when docker commit runs.

Does localstack has some particularity for this use case?

Thanks

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack-pro:3.8
    ports:
      # Now only required if you need to access LocalStack from the host
      - "127.0.0.1:4566:4566"
      # Now only required if you need to access LocalStack from the host
      - "127.0.0.1:4510-4559:4510-4559"
    environment:
      - LOCALSTACK_AUTH_TOKEN=$LOCALSTACK_AUTH_TOKEN
      - DEBUG=1
      - PERSISTENCE=1 
      - SNAPSHOT_SAVE_STRATEGY=ON_REQUEST
      - LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT=300
      - LAMBDA_DOCKER_NETWORK=digital-localstack_ls
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./localstack-volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
    networks:
      ls:
        # Set the container IP address in the 10.0.2.0/24 subnet
        ipv4_address: 10.0.2.20

2

Answers


  1. You have volume mounted. As per docker documentation commit doesn’t contain changes in volume or bind mount. So, Just remove volumes and use COPY to copy data of ${LOCALSTACK_VOLUME_DIR:-./localstack-volume}

    Login or Signup to reply.
  2. LocalStack person here. We do have features specific to your use case. We have a bunch of persistence tools that could potentially help here including saving and loading state or cloud pods, for instance.

    My colleague wrote a blog post about persistence and integration tests that seems similar to what you are looking for (though the example is specific to using GitHub Actions).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search