Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: Update Docker Compose command and add deployment script #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

miskibin
Copy link
Owner

Checklist before requesting a review

  • A self-review of the code has been performed
  • Commit messages and code follows our guidelines and standards
  • Tests have been added or updated where appropriate
  • Changes generate no new errors or warnings
  • There are no open Pull Requests for the same update/change
  • Any dependent changes have been merged and published
  • This change is covered by a project issue ticket

Change Description

How Has This Been Tested?

Does this PR introduce a breaking change?

Related Issue

Does this change resolve any open issues?

Fixes #(issue number)

# Update Nginx configuration to route traffic to new stack
sed -i "s/proxy_pass http:\/\/web:$current_backend_port/proxy_pass http:\/\/web:$new_backend_port/" nginx.conf
sed -i "s/proxy_pass http:\/\/frontend:$current_frontend_port/proxy_pass http:\/\/frontend:$new_frontend_port/" nginx.conf
docker service update --force $STACK_NAME-$new_color_nginx

Choose a reason for hiding this comment

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

⚠️ Codacy found a medium Code Style issue: Double quote to prevent globbing and word splitting.

The issue identified by ShellCheck is related to the lack of double quotes around the variable $STACK_NAME-$new_color_nginx. Without quotes, if the variable contains spaces or special characters, it could lead to unexpected behavior due to globbing (filename expansion) or word splitting.

To fix this issue, you should wrap the variable in double quotes. Here is the corrected line:

Suggested change
docker service update --force $STACK_NAME-$new_color_nginx
docker service update --force "$STACK_NAME-$new_color_nginx"

This comment was generated by an experimental AI tool.

set -e

# Configuration
REPO_URL="https://github.com/miskibin/sejm-stats.git"

Choose a reason for hiding this comment

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

⚠️ Codacy found a medium Error Prone issue: REPO_URL appears unused. Verify use (or export if used externally).

The issue identified by ShellCheck is that the variable REPO_URL is defined but not used anywhere within the script. This can be problematic as it might indicate unnecessary code or potential mistakes where the variable was intended to be used but was forgotten.

To fix this, you should either use the REPO_URL variable somewhere in your script or remove it if it's not needed. If the intention was to use REPO_URL for cloning the repository, you should add the appropriate command.

Here’s a single line change to use REPO_URL for cloning the repository:

Suggested change
REPO_URL="https://github.com/miskibin/sejm-stats.git"
git clone "$REPO_URL" "$REPO_PATH"

This line should be added at the appropriate place in your script where the repository needs to be cloned.


This comment was generated by an experimental AI tool.


sed -e "s/BACKEND_PORT_PLACEHOLDER/$backend_port/g" \
-e "s/FRONTEND_PORT_PLACEHOLDER/$frontend_port/g" \
docker-compose.yml > docker-compose-$color.yml

Choose a reason for hiding this comment

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

⚠️ Codacy found a medium Code Style issue: Double quote to prevent globbing and word splitting.

The issue identified by ShellCheck is related to the use of unquoted variables, which can lead to unintended globbing (filename expansion) and word splitting. In this case, the variable $color is not quoted, which means if it contains spaces or special characters, it could cause unexpected behavior.

To fix this issue, you should add double quotes around the variable to ensure it is treated as a single word and to prevent any unwanted expansions.

Here's the suggested code change:

Suggested change
docker-compose.yml > docker-compose-$color.yml
sed -e "s/BACKEND_PORT_PLACEHOLDER/$backend_port/g" -e "s/FRONTEND_PORT_PLACEHOLDER/$frontend_port/g" docker-compose.yml > "docker-compose-$color.yml"

This comment was generated by an experimental AI tool.

sed -e "s/BACKEND_PORT_PLACEHOLDER/$backend_port/g" \
-e "s/FRONTEND_PORT_PLACEHOLDER/$frontend_port/g" \
docker-compose.yml > docker-compose-$color.yml
docker stack deploy -c docker-compose-$color.yml $STACK_NAME-$color

Choose a reason for hiding this comment

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

⚠️ Codacy found a medium Code Style issue: Double quote to prevent globbing and word splitting.

The issue identified by ShellCheck is related to the potential for word splitting and globbing, which can occur when variables are not properly quoted. In the line docker stack deploy -c docker-compose-$color.yml $STACK_NAME-$color, the variables $color and $STACK_NAME should be enclosed in double quotes to prevent unintended behavior if they contain spaces or special characters.

Here's the suggested fix:

Suggested change
docker stack deploy -c docker-compose-$color.yml $STACK_NAME-$color
docker stack deploy -c "docker-compose-$color.yml" "$STACK_NAME-$color"

This comment was generated by an experimental AI tool.

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

Successfully merging this pull request may close these issues.

1 participant