- Getting containers ready for the cloud
This commit is contained in:
81
docker/build_tag_and_push.sh
Executable file
81
docker/build_tag_and_push.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source the environment setup script
|
||||
if [ -f "./docker_env_switch.sh" ]; then
|
||||
source ./docker_env_switch.sh dev
|
||||
else
|
||||
echo "Error: set_environment.sh not found in the current directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Docker Hub username
|
||||
USERNAME="josakola"
|
||||
|
||||
# List of all your services
|
||||
ALL_SERVICES=("eveai_app" "eveai_workers" "eveai_chat" "eveai_chat_workers" "nginx")
|
||||
|
||||
# Function to build, tag and push an image
|
||||
build_tag_and_push() {
|
||||
local service=$1
|
||||
echo "Building, tagging, and pushing ${service}..."
|
||||
|
||||
# Extract dockerfile and context paths from Docker Compose configuration
|
||||
local dockerfile_path
|
||||
local context_path
|
||||
|
||||
dockerfile_path=$(docker compose -f "$COMPOSE_FILE" config | grep "${service}" -A 10 | grep "dockerfile" | awk '{print $2}')
|
||||
context_path=$(docker compose -f "$COMPOSE_FILE" config | grep "${service}" -A 10 | grep "context" | awk '{print $2}')
|
||||
|
||||
# Verify the paths
|
||||
echo "Dockerfile path: ${dockerfile_path}"
|
||||
echo "Context path: ${context_path}"
|
||||
|
||||
# Use docker buildx to build the image
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t "${USERNAME}/${service}:latest" \
|
||||
--push \
|
||||
--file "${dockerfile_path}" \
|
||||
"${context_path}"
|
||||
}
|
||||
|
||||
# Function to check if a service is in the ALL_SERVICES array
|
||||
service_exists() {
|
||||
local service=$1
|
||||
for s in "${ALL_SERVICES[@]}"; do
|
||||
if [[ "$s" == "$service" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Ensure we're using buildx
|
||||
docker buildx create --use
|
||||
|
||||
# If COMPOSE_FILE is not set, use a default value
|
||||
if [ -z "$COMPOSE_FILE" ]; then
|
||||
COMPOSE_FILE="compose_dev.yaml"
|
||||
echo "COMPOSE_FILE not set, using default: $COMPOSE_FILE"
|
||||
else
|
||||
echo "Using COMPOSE_FILE: $COMPOSE_FILE"
|
||||
fi
|
||||
|
||||
# If no arguments are provided, process all services
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No specific services provided. Processing all services..."
|
||||
for service in "${ALL_SERVICES[@]}"; do
|
||||
build_tag_and_push "$service"
|
||||
done
|
||||
else
|
||||
# Process only the specified services
|
||||
for service in "$@"; do
|
||||
if service_exists "$service"; then
|
||||
build_tag_and_push "$service"
|
||||
else
|
||||
echo "Warning: ${service} is not a recognized service name. Skipping."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Done!"
|
||||
@@ -11,17 +11,33 @@
|
||||
x-common-variables: &common-variables
|
||||
DB_HOST: db
|
||||
DB_USER: luke
|
||||
DB_PASS: Skywalker!
|
||||
DB_PASS: 'Skywalker!'
|
||||
DB_NAME: eveai
|
||||
DB_PORT: '5432'
|
||||
FLASK_ENV: development
|
||||
FLASK_DEBUG: 1
|
||||
FLASK_DEBUG: true
|
||||
SECRET_KEY: '97867c1491bea5ee6a8e8436eb11bf2ba6a69ff53ab1b17ecba450d0f2e572e1'
|
||||
SECURITY_PASSWORD_SALT: '228614859439123264035565568761433607235'
|
||||
MAIL_USERNAME: eveai_super@flow-it.net
|
||||
MAIL_PASSWORD: '$6xsWGbNtx$CFMQZqc*'
|
||||
OPENAI_API_KEY: 'sk-proj-8R0jWzwjL7PeoPyMhJTZT3BlbkFJLb6HfRB2Hr9cEVFWEhU7'
|
||||
GROQ_API_KEY: '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'
|
||||
ANTHROPIC_API_KEY: 'sk-ant-api03-c2TmkzbReeGhXBO5JxNH6BJNylRDonc9GmZd0eRbrvyekec2'
|
||||
PORTKEY_API_KEY: 'T2Dt4QTpgCvWxa1OftYCJtj7NcDZ'
|
||||
JWT_SECRET_KEY: 'bsdMkmQ8ObfMD52yAFg4trrvjgjMhuIqg2fjDpD/JqvgY0ccCcmlsEnVFmR79WPiLKEA3i8a5zmejwLZKl4v9Q=='
|
||||
API_ENCRYPTION_KEY: 'xfF5369IsredSrlrYZqkM9ZNrfUASYYS6TCcAR9UKj4='
|
||||
MINIO_ENDPOINT: minio:9000
|
||||
MINIO_ACCESS_KEY: minioadmin
|
||||
MINIO_SECRET_KEY: minioadmin
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
build:
|
||||
context: ../nginx
|
||||
dockerfile: Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
ports:
|
||||
- 80:80
|
||||
- 8080:8080
|
||||
@@ -39,6 +55,9 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: ./docker/eveai_app/Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
ports:
|
||||
- 5001:5001
|
||||
environment:
|
||||
@@ -69,6 +88,9 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: ./docker/eveai_workers/Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
# ports:
|
||||
# - 5001:5001
|
||||
environment:
|
||||
@@ -98,6 +120,9 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: ./docker/eveai_chat/Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
ports:
|
||||
- 5002:5002
|
||||
environment:
|
||||
@@ -125,6 +150,9 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: ./docker/eveai_chat_workers/Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
# ports:
|
||||
# - 5001:5001
|
||||
environment:
|
||||
123
docker/compose_stackhero.yaml
Normal file
123
docker/compose_stackhero.yaml
Normal file
@@ -0,0 +1,123 @@
|
||||
# Comments are provided throughout this file to help you get started.
|
||||
# If you need more help, visit the Docker Compose reference guide at
|
||||
# https://docs.docker.com/go/compose-spec-reference/
|
||||
|
||||
# Here the instructions define your application as a service called "server".
|
||||
# This service is built from the Dockerfile in the current directory.
|
||||
# You can add other services your application may depend on here, such as a
|
||||
# database or a cache. For examples, see the Awesome Compose repository:
|
||||
# https://github.com/docker/awesome-compose
|
||||
|
||||
x-common-variables: &common-variables
|
||||
DB_HOST: bswnz4.stackhero-network.com
|
||||
DB_USER: luke_skywalker
|
||||
DB_PASS: 2MK&1rHmWEydE2rFuJLq*ls%tdkPAk2
|
||||
DB_NAME: eveai
|
||||
DB_PORT: '5945'
|
||||
FLASK_ENV: production
|
||||
FLASK_DEBUG: false
|
||||
SECRET_KEY: '38wg8e1lvhlvcu0apr95n8o07axf244lzaa7b7djh7itrf8jnyyh1lkuco529w'
|
||||
SECURITY_PASSWORD_SALT: '166448071751628781809462050022558634074'
|
||||
MAIL_USERNAME: 'evie_admin@askeveai.com'
|
||||
MAIL_PASSWORD: 's5D%R#y^v!s&6Z^i0k&'
|
||||
REDIS_USER: admin
|
||||
REDIS_PASS: 'b32vtDtLriSY1fL2zGrZg8IZKI0g9ucsLtVNanRFAras6oZ51wjVNB1Y05uG7uEw'
|
||||
REDIS_URL: 8bciqc.stackhero-network.com
|
||||
REDIS_PORT: '9961'
|
||||
OPENAI_API_KEY: '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'
|
||||
GROQ_API_KEY: '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'
|
||||
ANTHROPIC_API_KEY: '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'
|
||||
PORTKEY_API_KEY: '3C+zAGR8pCalevBXFVc0l8R2MPYc'
|
||||
JWT_SECRET_KEY: '0d99e810e686ea567ef305d8e9b06195c4db482952e19276590a726cde60a408'
|
||||
API_ENCRYPTION_KEY: 'Ly5XYWwEKiasfAwEqdEMdwR-k0vhrq6QPYd4whEROB0='
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- 80:80
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- ../nginx:/etc/nginx
|
||||
- ../nginx/sites-enabled:/etc/nginx/sites-enabled
|
||||
- ../nginx/static:/etc/nginx/static
|
||||
- ../nginx/public:/etc/nginx/public
|
||||
- ./logs/nginx:/var/log/nginx
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.api.rule=Host(`evie.askeveai.com`)"
|
||||
- "traefik.http.services.nginx.loadbalancer.server.port=80"
|
||||
depends_on:
|
||||
- eveai_app
|
||||
- eveai_chat
|
||||
|
||||
eveai_app:
|
||||
image: josakola/eveai_app:latest
|
||||
ports:
|
||||
- 5001:5001
|
||||
environment:
|
||||
<<: *common-variables
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5001/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
command: ["sh", "-c", "scripts/start_eveai_app.sh"]
|
||||
|
||||
eveai_workers:
|
||||
image: josakola/eveai_workers:latest
|
||||
# ports:
|
||||
# - 5001:5001
|
||||
environment:
|
||||
<<: *common-variables
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
# healthcheck:
|
||||
# test: [ "CMD", "curl", "-f", "http://localhost:5001/health" ]
|
||||
# interval: 10s
|
||||
# timeout: 5s
|
||||
# retries: 5
|
||||
command: [ "sh", "-c", "scripts/start_eveai_workers.sh" ]
|
||||
|
||||
eveai_chat:
|
||||
image: josakola/eveai_chat:latest
|
||||
ports:
|
||||
- 5002:5002
|
||||
environment:
|
||||
<<: *common-variables
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
healthcheck:
|
||||
test: [ "CMD", "curl", "-f", "http://localhost:5002/health" ] # Adjust based on your health endpoint
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
command: ["sh", "-c", "scripts/start_eveai_chat.sh"]
|
||||
|
||||
eveai_chat_workers:
|
||||
image: josakola/eveai_chat_workers:latest
|
||||
# ports:
|
||||
# - 5001:5001
|
||||
environment:
|
||||
<<: *common-variables
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
# healthcheck:
|
||||
# test: [ "CMD", "curl", "-f", "http://localhost:5001/health" ]
|
||||
# interval: 10s
|
||||
# timeout: 5s
|
||||
# retries: 5
|
||||
command: [ "sh", "-c", "scripts/start_eveai_chat_workers.sh" ]
|
||||
|
||||
|
||||
#volumes:
|
||||
# minio_data:
|
||||
# db-data:
|
||||
# redis-data:
|
||||
# tenant-files:
|
||||
#secrets:
|
||||
# db-password:
|
||||
# file: ./db/password.txt
|
||||
|
||||
57
docker/docker_env_switch.sh
Executable file
57
docker/docker_env_switch.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to display usage information
|
||||
usage() {
|
||||
echo "Usage: source $0 [dev|prod]"
|
||||
echo " dev : Switch to development environment"
|
||||
echo " prod : Switch to production environment"
|
||||
}
|
||||
|
||||
# Check if the script is sourced
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
echo "Error: This script must be sourced, not executed directly."
|
||||
echo "Please run: source $0 [dev|prod]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if an argument is provided
|
||||
if [ $# -eq 0 ]; then
|
||||
usage
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Set variables based on the environment
|
||||
case $1 in
|
||||
dev)
|
||||
DOCKER_CONTEXT="default"
|
||||
COMPOSE_FILE="compose_dev.yaml"
|
||||
;;
|
||||
prod)
|
||||
DOCKER_CONTEXT="mxz536.stackhero-network.com"
|
||||
COMPOSE_FILE="compose_stackhero.yaml"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid environment. Use 'dev' or 'prod'."
|
||||
usage
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Switch Docker context
|
||||
echo "Switching to Docker context: $DOCKER_CONTEXT"
|
||||
docker context use $DOCKER_CONTEXT
|
||||
|
||||
# Set the COMPOSE_FILE environment variable
|
||||
export COMPOSE_FILE=$COMPOSE_FILE
|
||||
echo "Set COMPOSE_FILE to $COMPOSE_FILE"
|
||||
|
||||
# Define aliases for common Docker commands
|
||||
alias docker-compose="docker compose -f $COMPOSE_FILE"
|
||||
alias dc="docker compose -f $COMPOSE_FILE"
|
||||
alias dcup="docker compose -f $COMPOSE_FILE up -d"
|
||||
alias dcdown="docker compose -f $COMPOSE_FILE down"
|
||||
alias dcps="docker compose -f $COMPOSE_FILE ps"
|
||||
alias dclogs="docker compose -f $COMPOSE_FILE logs"
|
||||
|
||||
echo "Docker environment switched to $1"
|
||||
echo "You can now use 'docker-compose', 'dc', 'dcup', 'dcdown', 'dcps', and 'dclogs' commands"
|
||||
14
docker/stackhero_link.sh
Executable file
14
docker/stackhero_link.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
# HOST is your Stackhero for Docker instance domain name (mxz536.stackhero-network.com).
|
||||
# SERVICE_ID is your Stackhero service ID.
|
||||
# CERTIFICATES_PASSWORD is the password defined in your Stackhero for Docker configuration.
|
||||
(export HOST="mxz536.stackhero-network.com"
|
||||
export SERVICE_ID="svc-rlaeva"
|
||||
export CERTIFICATES_PASSWORD="OonfQaQerGLLsWPKmnudyghFilIcPJRW"
|
||||
|
||||
cd /tmp/ \
|
||||
&& curl -o certificates.tar https://docker:$CERTIFICATES_PASSWORD@$HOST/stackhero/docker/certificates.tar \
|
||||
&& tar -xf certificates.tar \
|
||||
&& (docker context rm -f $HOST 2> /dev/null || true) \
|
||||
&& docker context create $HOST \
|
||||
--description "$SERVICE_ID ($HOST)" \
|
||||
--docker "host=tcp://$HOST:2376,ca=ca.pem,cert=cert.pem,key=key.pem")
|
||||
Reference in New Issue
Block a user