Announcement

Collapse
No announcement yet.

Connect AWS S3 storage to FARGATE container

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Connect AWS S3 storage to FARGATE container

    Hi there!
    I'm tryng to deploy EspoCRM in cloud-native way using image for ECS FARGATE in CF template, but I'm running into a problem with configuration change.

    To use S3 as default storage I need to change 2 config files - config.php and config-internal.php. I assume they are generated during container initialization, because I couldn't change them using official espocrm image as origin for my Dockerfile and custom entrypoint with sed and awk commands, for example:

    Dockerfile
    Code:
    FROM espocrm/espocrm:latest
    
    COPY entrypoint.sh /entrypoint.sh
    
    ENTRYPOINT ["/entrypoint.sh"]
    entrypoint.sh
    Code:
    # Modify the config.php file
    sed -i "s|'defaultFileStorage' => 'EspoUploadDir'|'defaultFileStorage' => 'AwsS3'|" /var/www/html/data/config.php
    
    # Add the additional configuration to config-internal.php
    awk 'NR==32{print " '\''awsS3Storage'\'' => ["}1' /var/www/html/data/config-internal.php > tmp && mv tmp /var/www/html/data/config-internal.php
    echo " 'bucketName' => 'bucket'," >> /var/www/html/data/config-internal.php
    echo " 'credentials' => [" >> /var/www/html/data/config-internal.php
    echo " 'key' => 'key'," >> /var/www/html/data/config-internal.php
    echo " 'secret' => 'secret'," >> /var/www/html/data/config-internal.php
    echo " ]," >> /var/www/html/data/config-internal.php
    echo " 'region' => 'ca-central-1'," >> /var/www/html/data/config-internal.php
    echo " ]," >> /var/www/html/data/config-internal.php​
    I recieve next errors:

    Code:
    2023-10-22 15:02:13 sed: can't read /var/www/html/data/config.php: No such file or directory
    2023-10-22 15:02:13 awk: cannot open /var/www/html/data/config-internal.php (No such file or directory)
    2023-10-22 15:02:13 /entrypoint.sh: 14: cannot create /var/www/html/data/config-internal.php: Directory nonexistent
    2023-10-22 15:02:13 /entrypoint.sh: 15: cannot create /var/www/html/data/config-internal.php: Directory nonexistent
    2023-10-22 15:02:13 /entrypoint.sh: 16: cannot create /var/www/html/data/config-internal.php: Directory nonexistent
    2023-10-22 15:02:13 /entrypoint.sh: 17: cannot create /var/www/html/data/config-internal.php: Directory nonexistent
    2023-10-22 15:02:13 /entrypoint.sh: 18: cannot create /var/www/html/data/config-internal.php: Directory nonexistent
    2023-10-22 15:02:13 /entrypoint.sh: 19: cannot create /var/www/html/data/config-internal.php: Directory nonexistent
    2023-10-22 15:02:13 /entrypoint.sh: 20: cannot create /var/www/html/data/config-internal.php: Directory nonexistent​
    I tried to just copy changed configs to image, but the container couldn't start either. I receive 403 error:

    Code:
    2023-10-22 15:05:46 [Sun Oct 22 13:05:46.357998 2023] [autoindex:error] [pid 26] [client 172.17.0.1:42270] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
    2023-10-22 15:05:46 172.17.0.1 - - [22/Oct/2023:13:05:46 +0000] "GET / HTTP/1.1" 403 491 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"​
    Is there any way to have S3 configuration out of the box?

  • #2
    Did you figure this out?

    Comment

    Working...
    X