pivotdude / laravel-template

0 stars 1 forks source link

Sweep(slow): Make a launch in production mode for laravel using apache server, fix Dockerfile and docker-compose #18

Closed pivotdude closed 1 year ago

pivotdude commented 1 year ago
Checklist - [X] `Backend.Dockerfile` ✅ Commit [`d62a2ec`](https://github.com/pivotdude/laravel-template/commit/d62a2ecdec75a0352de45c75ac90d4017808191d)
• Change the base image to an image that includes Apache and PHP, such as "php:7.4-apache". • Copy the Laravel application's source code into the Docker image. • Set the working directory to the location of the Laravel application in the Docker image. • Install the necessary PHP extensions and enable Apache's mod_rewrite module. • Change the Apache configuration to point the document root to the Laravel application's public directory. • Copy the Laravel application's .env.docker file to .env in the Docker image. • Run composer install to install the Laravel application's dependencies. • Change the CMD instruction to start Apache in the foreground.
Sandbox Execution Logs
trunk init 1/13 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 11 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (1 github-workflow file)
  checkov 2.4.9 (2 docker, 3 json, 4 yaml files)
  git-diff-check (96 files)
  hadolint 2.12.0 (2 docker files) (created .hadolint.yaml)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 css, 2 javascript, 3 json, 1 markdown, 4 typescript, 4 yaml files)
  terrascan 1.18.3 (2 docker files)
  trivy 0.45.0 (2 docker, 1 lockfile, 4 yaml files)
  trufflehog 3.56.0 (96 files)
  yamllint 1.32.0 (4 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt Backend.Dockerfile 2/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 3/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:27:1
  0:0  high    Add HEALTHCHECK instruction in your Dockerfile                                   trivy/DS026             
  0:0  high    Specify at least 1 USER command in Dockerfile with non-root user as argument     trivy/DS002             
  1:1  high    Ensure that a user for the container has been created                            checkov/CKV_DOCKER_3    
  1:1  high    Ensure that HEALTHCHECK instructions have been added to container images         checkov/CKV_DOCKER_2    
 27:1  medium  Ensure that there is only be one CMD instruction in a Dockerfile. If you list    terrascan/AC_DOCKER_0053
               more than one CMD then only the last CMD will take effect                                                
 55:1  medium  Ensure that there is only be one CMD instruction in a Dockerfile. If you list    terrascan/AC_DOCKER_0053
               more than one CMD then only the last CMD will take effect                                                
Checked 1 file
5 existing issues
✖ 1 new issue
trunk fmt Backend.Dockerfile 4/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 5/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 6/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 7/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 8/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 9/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 10/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 11/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 12/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 13/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
- [X] `docker-compose.yml` ✅ Commit [`8c9a793`](https://github.com/pivotdude/laravel-template/commit/8c9a7939f2f09451ed14ec29b3fd61307d5c4eb6)
• Update the build context for the "laravel" service to point to the location of the updated Dockerfile. • Ensure that the "laravel" service is connected to the "db" service.
Sandbox Execution Logs
trunk init 1/4 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 11 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (1 github-workflow file)
  checkov 2.4.9 (2 docker, 3 json, 4 yaml files)
  git-diff-check (96 files)
  hadolint 2.12.0 (2 docker files) (created .hadolint.yaml)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 css, 2 javascript, 3 json, 1 markdown, 4 typescript, 4 yaml files)
  terrascan 1.18.3 (2 docker files)
  trivy 0.45.0 (2 docker, 1 lockfile, 4 yaml files)
  trufflehog 3.56.0 (96 files)
  yamllint 1.32.0 (4 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt docker-compose.yml 2/4 ❌ (`1`)

  FAILURES  
 prettier  docker-compose.yml  .trunk/out/ypIWI.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 0 files
✖ No issues, 1 failure
trunk fmt docker-compose.yml 3/4 ✓

 ✔ Formatted docker-compose.yml
Re-checking autofixed files...

Checked 1 file
✔ No issues
trunk check --fix docker-compose.yml 4/4 ✓

  ISSUES  
docker-compose.yml:10:1
 10:1   high  Base64 High Entropy String                          checkov/CKV_SECRET_6   
 15:20  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:27  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:41  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:49  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:55  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 51:12  high  empty value in block mapping                        yamllint/empty-values  
Checked 1 file
7 existing issues
- [X] `config/database.php` ✅ Commit [`681a405`](https://github.com/pivotdude/laravel-template/commit/681a405bb5adefcce1e1486776be3e272195f505)
• Update the database connection settings to use the environment variables defined in the .env file.
Sandbox Execution Logs
trunk init 1/3 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 11 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (1 github-workflow file)
  checkov 2.4.9 (2 docker, 3 json, 4 yaml files)
  git-diff-check (96 files)
  hadolint 2.12.0 (2 docker files) (created .hadolint.yaml)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 css, 2 javascript, 3 json, 1 markdown, 4 typescript, 4 yaml files)
  terrascan 1.18.3 (2 docker files)
  trivy 0.45.0 (2 docker, 1 lockfile, 4 yaml files)
  trufflehog 3.56.0 (96 files)
  yamllint 1.32.0 (4 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt config/database.php 2/3 ✓

Found no applicable linters for the requested path
trunk check --fix config/database.php 3/3 ✓

Checked 1 file
✔ No issues
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/pivotdude/laravel-template/pull/19.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 4 GPT-4 tickets left for the month and 2 for the day. For more GPT-4 tickets, visit our payment portal.


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/pivotdude/laravel-template/blob/01cd35b1aee943e0e404e4d2eaaf4e7bc32be184/config/app.php#L1-L122 https://github.com/pivotdude/laravel-template/blob/01cd35b1aee943e0e404e4d2eaaf4e7bc32be184/Backend.Dockerfile#L1-L19 https://github.com/pivotdude/laravel-template/blob/01cd35b1aee943e0e404e4d2eaaf4e7bc32be184/config/database.php#L1-L150 https://github.com/pivotdude/laravel-template/blob/01cd35b1aee943e0e404e4d2eaaf4e7bc32be184/public/index.php#L1-L54 https://github.com/pivotdude/laravel-template/blob/01cd35b1aee943e0e404e4d2eaaf4e7bc32be184/docker-compose.yml#L1-L51

I also found some related docs:


Step 2: ⌨️ Coding

trunk init 1/13 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 11 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (1 github-workflow file)
  checkov 2.4.9 (2 docker, 3 json, 4 yaml files)
  git-diff-check (96 files)
  hadolint 2.12.0 (2 docker files) (created .hadolint.yaml)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 css, 2 javascript, 3 json, 1 markdown, 4 typescript, 4 yaml files)
  terrascan 1.18.3 (2 docker files)
  trivy 0.45.0 (2 docker, 1 lockfile, 4 yaml files)
  trufflehog 3.56.0 (96 files)
  yamllint 1.32.0 (4 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt Backend.Dockerfile 2/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 3/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:27:1
  0:0  high    Add HEALTHCHECK instruction in your Dockerfile                                   trivy/DS026             
  0:0  high    Specify at least 1 USER command in Dockerfile with non-root user as argument     trivy/DS002             
  1:1  high    Ensure that a user for the container has been created                            checkov/CKV_DOCKER_3    
  1:1  high    Ensure that HEALTHCHECK instructions have been added to container images         checkov/CKV_DOCKER_2    
 27:1  medium  Ensure that there is only be one CMD instruction in a Dockerfile. If you list    terrascan/AC_DOCKER_0053
               more than one CMD then only the last CMD will take effect                                                
 55:1  medium  Ensure that there is only be one CMD instruction in a Dockerfile. If you list    terrascan/AC_DOCKER_0053
               more than one CMD then only the last CMD will take effect                                                
Checked 1 file
5 existing issues
✖ 1 new issue
trunk fmt Backend.Dockerfile 4/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 5/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 6/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 7/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 8/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 9/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 10/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 11/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue
trunk fmt Backend.Dockerfile 12/13 ✓

Found no applicable linters for the requested path
trunk check --fix Backend.Dockerfile 13/13 ❌ (`1`)

  ISSUES  
Backend.Dockerfile:1:1
 1:1  low  Ensure that HEALTHCHECK is being used.  terrascan/AC_DOCKER_0047
Checked 1 file
✖ 1 new issue

trunk init 1/4 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 11 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (1 github-workflow file)
  checkov 2.4.9 (2 docker, 3 json, 4 yaml files)
  git-diff-check (96 files)
  hadolint 2.12.0 (2 docker files) (created .hadolint.yaml)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 css, 2 javascript, 3 json, 1 markdown, 4 typescript, 4 yaml files)
  terrascan 1.18.3 (2 docker files)
  trivy 0.45.0 (2 docker, 1 lockfile, 4 yaml files)
  trufflehog 3.56.0 (96 files)
  yamllint 1.32.0 (4 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt docker-compose.yml 2/4 ❌ (`1`)

  FAILURES  
 prettier  docker-compose.yml  .trunk/out/ypIWI.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 0 files
✖ No issues, 1 failure
trunk fmt docker-compose.yml 3/4 ✓

 ✔ Formatted docker-compose.yml
Re-checking autofixed files...

Checked 1 file
✔ No issues
trunk check --fix docker-compose.yml 4/4 ✓

  ISSUES  
docker-compose.yml:10:1
 10:1   high  Base64 High Entropy String                          checkov/CKV_SECRET_6   
 15:20  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:27  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:41  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:49  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 15:55  high  string value is redundantly quoted with any quotes  yamllint/quoted-strings
 51:12  high  empty value in block mapping                        yamllint/empty-values  
Checked 1 file
7 existing issues

trunk init 1/3 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 11 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (1 github-workflow file)
  checkov 2.4.9 (2 docker, 3 json, 4 yaml files)
  git-diff-check (96 files)
  hadolint 2.12.0 (2 docker files) (created .hadolint.yaml)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 css, 2 javascript, 3 json, 1 markdown, 4 typescript, 4 yaml files)
  terrascan 1.18.3 (2 docker files)
  trivy 0.45.0 (2 docker, 1 lockfile, 4 yaml files)
  trufflehog 3.56.0 (96 files)
  yamllint 1.32.0 (4 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt config/database.php 2/3 ✓

Found no applicable linters for the requested path
trunk check --fix config/database.php 3/3 ✓

Checked 1 file
✔ No issues


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/update-dockerfile-docker-compose.

.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord