astro-paper icon indicating copy to clipboard operation
astro-paper copied to clipboard

Dockerfile added to build static files and serve with NGINX image

Open michealch opened this issue 4 months ago • 4 comments

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

michealch avatar Feb 09 '24 22:02 michealch

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?

satnaing avatar Feb 19 '24 09:02 satnaing

@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 avatar Feb 19 '24 14:02 michealch

@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 avatar Feb 19 '24 14:02 michealch

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

michealch avatar Mar 31 '24 11:03 michealch