FkJ
FkJ

Reputation: 1634

Custom localstack docker image

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?

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

Upvotes: -2

Views: 127

Answers (1)

Munir Khakhi
Munir Khakhi

Reputation: 11

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}

Upvotes: 1

Related Questions