Skip to content

Instantly share code, notes, and snippets.

@darrylmorley
Last active November 5, 2024 11:49
Show Gist options
  • Save darrylmorley/77d676e0be01862bcd41ad68e6ae9ea8 to your computer and use it in GitHub Desktop.
Save darrylmorley/77d676e0be01862bcd41ad68e6ae9ea8 to your computer and use it in GitHub Desktop.
Create Docker Image - Bash Alias

Bash Alias to Create a Docker Image

alias docker-build='function \_docker_deploy() { \
 image_name=$(basename "$PWD"); \
 short_hash=$(git rev-parse --short HEAD); \
  full_tag="registry.digitalocean.com/shootingsupplies/${image_name}:${short_hash}"; \
  docker compose build --no-cache; \
  docker tag "${image_name}" "$full_tag"; \
  docker push "$full_tag"; \
 echo "Image pushed as $full_tag"; \
}; \_docker_deploy'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment