How can I make my localstack script file executable for docker-compose

33 views Asked by At

I have followed the guide here and I successfully have the result I wanted. In my case, the s3 buckets I need are created.

I want to get this process working without having to manually run the chmod +x createBucket.sh command manually, to allow other developers to have a more frictionless usage of the devkit I am working on.

Can I achieve this? Maybe by adding a command under localstack in docker-compose.yml.

Here are my files:

createBucket.sh:

#!/bin/bash

set -e

awslocal s3 mb s3://beta-ps-dev-doc-unscanned
awslocal s3 mb s3://templates
awslocal ses verify-email-identity --email-address [email protected]

localstack section of docker-compose.yml:

  localstack:
    image: localstack/localstack
    restart: "unless-stopped"
    ports:
      - '4566:4566'
    environment:
      - SERVICES=s3,ses,s3api
      - DEFAULT_REGION=eu-west-2
      - AWS_DEFAULT_REGION=eu-west-2
      - HOSTNAME_EXTERNAL=localhost
      - USE_SSL=false
      - DATA_DIR=/tmp/localstack/data
      - DEBUG=1
    volumes:
      - "./ares-localstack/localstack/scripts/createBucket.sh:/etc/localstack/init/ready.d/createBucket.sh"
      - "/tmp/localstack:/tmp/localstack1"

When running the above after manually making the file executable, the functionality works.

Without it, I get the error: PermissionError: [Errno 13] Permission denied: '/etc/localstack/init/ready.d/createBucket.sh'

Is there a way to automate the command that will make this file executable? I want to avoid including that as a readme step.

0

There are 0 answers