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 added to build static files and serve with NGINX image #262

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michealch
Copy link

@michealch michealch commented Feb 9, 2024

This PR includes a Dockerfile and .dockerignore that uses a two-stage build process: building static files with Node.js and serving them via a official NGINX image. The initial build stage uses node:lts to install dependencies and compile the application into static files. Second stage serve the static files with unprivileged NGINX Image.

Key Changes:

  1. Implemented multi-stage build to separate build and runtime environments.
  2. NGINX image for the runtime stage.

Build the Image by executing
docker build -t <image_name>:<image_tag> .

Run the Container by executing
docker run -p 8081:80 <image_name>:<image_tag>

The webpage should be accessible at http://localhost:8081

@satnaing
Copy link
Owner

Hello @michealch
Thanks for your contribution.
When I try running this, I've got the following warning (although it is working as expected)

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Do you know why this warning appears?

@michealch
Copy link
Author

michealch commented Feb 19, 2024

@satnaing fixed the issue by replacing the distroless image with official nginx unprivileged image. it should work fine now :)

The sample image is built for just sample purpose and only compatible with amd64.

@michealch
Copy link
Author

michealch commented Feb 19, 2024

@satnaing i will create another pull request to update readme and add the docker infos to it. Feel free to contact me, if you have any question regarding Docker or Container.

@michealch michealch changed the title Dockerfile added to build static files and serve with Distroless NGINX image Dockerfile added to build static files and serve with NGINX image Mar 31, 2024
@michealch
Copy link
Author

i have updated runtime image to official nginx image. Please merge the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants