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

DOCKERFILE Improvements #39

Open
Tracked by #42
decause-gov opened this issue Sep 1, 2023 · 0 comments
Open
Tracked by #42

DOCKERFILE Improvements #39

decause-gov opened this issue Sep 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@decause-gov
Copy link
Contributor

Issue Report

DOCKERFILE Improvements

Expected behavior

Running as a non-root user helps to avoid security risks; Using Security Headers is a good best practice.

Actual behavior

DOCKERFILE

The Dockerfile is structured in a multi-stage build format which is good for optimizing the
final image size. I'll walk you through each part of the Dockerfile and point out any concerns or
recommendations:

  1. Builder Stage (Node.js Build Phase):
  • FROM node:18.12.1-alpine as builder: You're using a specific version of Node.js
    with Alpine, which is a lightweight distro. This is a good practice as it minimizes
    the image size and reduces potential attack surfaces.

  • COPY package.json yarn.lock ./: Good! You're copying only the necessary files
    for the yarn install command. This takes advantage of Docker's caching
    mechanism and ensures faster builds if no dependencies change.

  • Recommendations: Consider using a non-root user even in the builder stage. Running as a non-root
    user is a security best practice.

  1. Production Environment (Nginx Server):
  • It would be beneficial to use a non-root user to run the Nginx process. By default,
    Nginx will run as root, which is not recommended in a container environment.
  • Consider adding security headers in your Nginx configuration for added security.
    Examples include: Strict-Transport-Security, Content-Security-Policy,
    X-Content-Type-Options, X-Frame-Options, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant