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

chore: fe deployment #85

Closed
wants to merge 3 commits into from
Closed

chore: fe deployment #85

wants to merge 3 commits into from

Conversation

bogdan-manole
Copy link
Collaborator

@bogdan-manole bogdan-manole commented Aug 9, 2023

Summary by CodeRabbit

Release Notes

Refactor:

  • Updated Dockerfile.web to improve build process and environment variable handling.
  • Modified docker-files/run-server.sh and docker-files/run-web.sh for better Docker image execution.
  • Enhanced flake.nix with new imports to include both server and web applications.
  • Adjusted react-web/.env.production environment variables for updated configuration.

New Feature:

  • Introduced new functions in web.nix for building, running, and pushing Docker images.

These changes aim to streamline the Docker image creation and deployment process, enhancing the overall performance and maintainability of the application.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 9, 2023

Image description CodeRabbit

Walkthrough

The changes primarily focus on Docker and Nix configurations for a web application. They include modifications to environment variables, Dockerfile commands, and scripts for running Docker images. The updates also introduce new Nix expressions for building, running, and pushing Docker images.

Changes

File(s) Summary
Dockerfile.web Modifications include commenting out the .env.local file copy command, adding --global serve flag to npm install, updating URLs in sed commands, removing .env files, changing port number, running npm run build, and updating ENTRYPOINT and CMD commands.
docker-files/run-server.sh, docker-files/run-web.sh Commands used to run Docker images have been updated. A new environment variable REACT_APP_BASE_URL has been added in run-web.sh.
docker-files/start_web.sh Removed the line setting the REACT_APP_BASE_URL environment variable and replaced npm start with serve -s build.
flake.nix Added two new imports, serverApps and webApps, from respective nix files. Modified the apps field in the flake object to include these imports.
react-web/.env.production Updated the REACT_APP_BASE_URL environment variable.
web.nix Introduced a new Nix expression defining three functions: loadDockerImage, runDockerImage, and pushDockerImage for Docker operations.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between dc3c0ff and cc0251f commits.
Files selected for processing (7)
  • Dockerfile.web (1 hunks)
  • docker-files/run-server.sh (1 hunks)
  • docker-files/run-web.sh (1 hunks)
  • docker-files/start_web.sh (1 hunks)
  • flake.nix (1 hunks)
  • react-web/.env.production (1 hunks)
  • web.nix (1 hunks)
Files skipped from review due to trivial changes (5)
  • docker-files/run-server.sh
  • docker-files/run-web.sh
  • docker-files/start_web.sh
  • react-web/.env.production
  • web.nix
Review comments generated (3)
  • Actionable : 3
  • LGTM (Skipped): 0
  • Noise Suppression (Skipped): 4

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Tag the bot with @coderabbitai in any review comment to ask it questions. The bot will not respond unless explicitly tagged.
  • A review comment is a comment on a diff or a file and not a comment on the PR itself.
  • You can use the mouse to select multiple lines of code to provide exact context to the bot.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

COPY ./docker-files/.env.local .
RUN npm install
#COPY ./docker-files/.env.local .
RUN npm install --global serve
Copy link
Contributor

Choose a reason for hiding this comment

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

Image description CodeRabbit

The serve package is being installed globally. This package is typically used to serve static files. If the application relies on other packages that were previously installed with npm install, those packages may not be available anymore. Please ensure that all necessary dependencies are still being installed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not bad 😄

RUN rm ./.env
#RUN rm ./.env.production

RUN npm run build
Copy link
Contributor

Choose a reason for hiding this comment

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

Image description CodeRabbit

The npm run build command is being executed. This command typically creates a production-ready version of the application. If there are any build scripts that need to be run before this command, they may not be executed anymore. Please ensure that all necessary build steps are still being performed.


COPY ./docker-files/start_web.sh .
RUN chmod +x ./start_web.sh

ENTRYPOINT [ "./start_web.sh" ]
#ENTRYPOINT [ "/bin/sh","-c","./start_web.sh"]
CMD [ "npm","start" ]
#CMD [ "npm","start" ]
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 9, 2023

Choose a reason for hiding this comment

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

Image description CodeRabbit

The CMD command has been commented out. This command specifies the default command that should be run when the container starts. If the ENTRYPOINT command does not start the application, it may not run when the container starts. Please ensure that the application is started correctly when the container runs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Image description CodeRabbit

@RSoulatIOHK Sure, I'd be happy to explain further.

In a Dockerfile, the CMD instruction provides defaults for an executing container. These can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction. The CMD values can be overridden when starting a container.

The ENTRYPOINT instruction allows you to configure a container that will run as an executable. It has two forms:

  1. The exec form, which is the preferred form: ENTRYPOINT ["executable", "param1", "param2"]
  2. The shell form, ENTRYPOINT command param1 param2

In your Dockerfile, you have commented out the CMD instruction and are using the ENTRYPOINT instruction to start the application. This means that when the Docker container starts, it will execute the start_web.sh script.

However, if the start_web.sh script does not start the application (for example, if it only prepares the environment), then the application will not run when the Docker container starts. This is because there is no CMD instruction to start the application.

To ensure that your application runs when the Docker container starts, you should either:

  • Make sure that the start_web.sh script starts the application.
  • Uncomment the CMD instruction so that it starts the application after the ENTRYPOINT instruction has completed.

I hope this clarifies things. Let me know if you have any other questions!

Copy link
Collaborator Author

@bogdan-manole bogdan-manole Aug 9, 2023

Choose a reason for hiding this comment

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

@CodeRabbit server build command from the last line of the entrypoint file starts the application from the build folder

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between cc0251f and 3dafa40 commits.
Files selected for processing (2)
  • docker-files/start_web.sh (1 hunks)
  • web.nix (1 hunks)
Files skipped from review due to trivial changes (1)
  • docker-files/start_web.sh
Review comments generated (1)
  • Actionable : 1
  • LGTM (Skipped): 0
  • Noise Suppression (Skipped): 3

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Tag the bot with @coderabbitai in any review comment to ask it questions. The bot will not respond unless explicitly tagged.
  • A review comment is a comment on a diff or a file and not a comment on the PR itself.
  • You can use the mouse to select multiple lines of code to provide exact context to the bot.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +12 to +16
${pkgs.docker}/bin/docker build -t ${imgAttributes.name}:${imgAttributes.tag} -f ./Dockerfile.web .
#${pkgs.docker}/bin/docker save ${imgAttributes.name}:${imgAttributes.tag} | ${pkgs.docker}/bin/docker load
#and now load the image into docker
#${pkgs.docker}/bin/docker image ls
'').outPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

Image description CodeRabbit

The command to save and load the Docker image is commented out. If this is intentional, consider removing these lines to avoid confusion.

-           #${pkgs.docker}/bin/docker save ${imgAttributes.name}:${imgAttributes.tag} | ${pkgs.docker}/bin/docker load
-           #and now load the image into docker
-           #${pkgs.docker}/bin/docker image ls

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 3dafa40 and bd11f3d commits.
Files selected for processing (2)
  • Dockerfile.web (1 hunks)
  • web.nix (1 hunks)
Files skipped from review due to trivial changes (2)
  • Dockerfile.web
  • web.nix
Review comments generated (0)
  • Actionable : 0
  • LGTM (Skipped): 0
  • Noise Suppression (Skipped): 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Tag the bot with @coderabbitai in any review comment to ask it questions. The bot will not respond unless explicitly tagged.
  • A review comment is a comment on a diff or a file and not a comment on the PR itself.
  • You can use the mouse to select multiple lines of code to provide exact context to the bot.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

@bogdan-manole
Copy link
Collaborator Author

the fe was detached from this repo

@bogdan-manole bogdan-manole deleted the chore/deploy-fe branch January 31, 2024 11:22
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.

1 participant