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

Merged
merged 6 commits into from
Jul 16, 2024

Conversation

michealch
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor Author

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

@satnaing
Copy link
Owner

satnaing commented Jul 14, 2024

@michealch
Thanks for your contribution.
Can you also add some instructions in README in order to run this Dockerfile?

@michealch
Copy link
Contributor Author

@satnaing README updated

@satnaing satnaing merged commit 47a3c86 into satnaing:main Jul 16, 2024
@eerison
Copy link
Contributor

eerison commented Jul 30, 2024

Hey @michealch

have you tried to use the docker-compose.yaml?
it will make you run astro paper on docker, you don't need to create a Dockerfile for this, or am I missing something here?

@michealch
Copy link
Contributor Author

Hey @eerison
The docker-compose.yaml you have mentioned is for dev purpose and not for production. Dockerfile is there to build container image with static files for production purpose.

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.

3 participants