Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement best practices in Docker image #1077

Merged
merged 7 commits into from
Jun 23, 2022

Conversation

VKTB
Copy link
Contributor

@VKTB VKTB commented May 31, 2022

Description

This PR implements best practices in the Docker image.

In summary, the changes do the following:

  • Removes the lines that sets the PATH because the image builds and the container works fine without it.
  • Build cache is leveraged in the build stage to reduce the build time when changes are made to the source code over and over again. This is accomplished by copying the package.json, tsconfig.json and yarn.lock files and installing the dependencies first, and then copying the source code and building the app. Because each COPY and RUN command is a new layer, this ensures that the layers for copying and installing the dependencies are cached when changes are made to the source code.
  • Configures the image so that containers run using the non-root www-data user account that the httpd image defines.
  • Uses setcap to allow non-root user accounts to bind to privileged ports (port 80 in this case) as these ports are only permitted to root by default. I found this solution in this article.
  • Changes the access rights for the Apache's logs directory from root to www-data user account.

Testing instructions

  • Review code
  • Check Actions build
  • Review changes to test coverage
  • Image builds successfully
  • Container starts successfully

@VKTB VKTB requested a review from moonraker595 May 31, 2022 13:04
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #1077 (958353c) into k8s-deployment (ea62522) will not change coverage.
The diff coverage is n/a.

@@               Coverage Diff               @@
##           k8s-deployment    #1077   +/-   ##
===============================================
  Coverage           97.94%   97.94%           
===============================================
  Files                  42       42           
  Lines                1557     1557           
  Branches              422      423    +1     
===============================================
  Hits                 1525     1525           
  Misses                 31       31           
  Partials                1        1           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d0fd3c...958353c. Read the comment docs.

Copy link

@moonraker595 moonraker595 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@VKTB VKTB merged commit 52f5627 into k8s-deployment Jun 23, 2022
@VKTB VKTB deleted the deployment/implement-best-practices branch June 23, 2022 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants