This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
3 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Check if "traefik" argument is provided | ||
if [ "$1" == "traefik" ]; then | ||
DOCKER_COMPOSE_COMMAND="docker-compose -f docker-compose.yml -f docker-compose.traefik.yml up -d" | ||
else | ||
DOCKER_COMPOSE_COMMAND="docker-compose -f docker-compose.yml up -d" | ||
fi | ||
|
||
# Read .env | ||
if [ -f .env ]; then | ||
# Source the .env file to set environment variables | ||
source .env | ||
else | ||
echo ".env file not found!" | ||
exit 1 # Exit with an error code | ||
exit 1 | ||
fi | ||
|
||
# Git repo | ||
if [ "$GIT" != "false" ]; then | ||
# Remove old git project | ||
rm -rf ./src | ||
# Make a new git clone | ||
git clone "$GIT_URL" src | ||
else | ||
if [ ! -d "./src" ]; then | ||
echo "src dir not found!" | ||
exit 1 # Exit with an error code | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Docker | ||
# - Remove old container (if it exists) | ||
docker-compose down | ||
|
||
# - Remove old image (if it exists) | ||
if [ "$(docker images -q "${ALIAS}-image" 2>/dev/null)" ]; then | ||
docker rmi "${ALIAS}-image" | ||
fi | ||
|
||
# - Build new docker image from Dockerfile using BuildKit for parallel builds | ||
DOCKER_BUILDKIT=1 docker build -t "${ALIAS}-image" . | ||
|
||
# Start new container using docker-compose based on the selected command | ||
eval "$DOCKER_COMPOSE_COMMAND" | ||
|
||
# Remove unused images | ||
docker image prune -a | ||
docker system prune --all |