diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..d68874eda --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,47 @@ +name: CI/CD for Odoo Docker Image to ACR + +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy (Development/Production)' + required: true + default: 'development' + odoo_version: + description: 'Odoo Version' + required: true + default: '18.0' + +jobs: + build-and-push: + name: Build and Push Odoo Docker Image to ACR + runs-on: ubuntu-latest + + steps: + # Checkout Odoo Docker repository + - name: Checkout Odoo Repository + uses: actions/checkout@v3 + with: + repository: trplgit/odoo-docker + token: ${{ secrets.GH_TOKEN }} + path: odoo-docker + + # Set up Docker buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + version: latest + + # Log in to Azure Container Registry + - name: Log in to Azure Container Registry + uses: azure/docker-login@v1 + with: + login-server: ${{ vars.ACR_NAME }}.azurecr.io + username: ${{ vars.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} + + # Build and Push Odoo Docker Image (odoo-18:latest) + - name: Build and Push Odoo Docker Image + run: | + docker build -f ./odoo-docker/${{ inputs.odoo_version }}/Dockerfile -t ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/odoo-18:latest ./odoo-docker/${{ inputs.odoo_version }} + docker push ${{ vars.ACR_NAME }}.azurecr.io/${{ inputs.environment }}/odoo-18:latest diff --git a/18.0/entrypoint.sh b/18.0/entrypoint.sh index f802bcb25..78e8f768e 100755 --- a/18.0/entrypoint.sh +++ b/18.0/entrypoint.sh @@ -2,18 +2,22 @@ set -e +# If PASSWORD_FILE is provided, read it if [ -v PASSWORD_FILE ]; then PASSWORD="$(< $PASSWORD_FILE)" fi -# set the postgres database host, port, user and password according to the environment -# and pass them as arguments to the odoo process if not present in the config file -: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}} -: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}} +# Set the postgres database host, port, user, and password according to the environment +# If the environment variable is not set, use default values +: ${HOST:=${DB_PORT_5432_TCP_ADDR:='postgres-container'}} +: ${PORT:=${DB_PORT_5432_TCP_PORT:=5433}} # Change default port to 5433 : ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}} : ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}} +# Arguments to pass to the Odoo process DB_ARGS=() + +# Function to check if the config file has any database-related config and override it function check_config() { param="$1" value="$2" @@ -23,26 +27,33 @@ function check_config() { DB_ARGS+=("--${param}") DB_ARGS+=("${value}") } + +# Call check_config for all necessary database parameters check_config "db_host" "$HOST" check_config "db_port" "$PORT" check_config "db_user" "$USER" check_config "db_password" "$PASSWORD" +# Main logic to start Odoo case "$1" in -- | odoo) shift + # If "scaffold", execute odoo scaffold command if [[ "$1" == "scaffold" ]] ; then exec odoo "$@" else + # Wait for PostgreSQL to be ready wait-for-psql.py ${DB_ARGS[@]} --timeout=30 - exec odoo "$@" "${DB_ARGS[@]}" + exec odoo "$@" "${DB_ARGS[@]}" # Start odoo with db args fi ;; -*) + # Wait for PostgreSQL to be ready if the arguments contain any option with - wait-for-psql.py ${DB_ARGS[@]} --timeout=30 - exec odoo "$@" "${DB_ARGS[@]}" + exec odoo "$@" "${DB_ARGS[@]}" # Start odoo with db args ;; *) + # If not odoo command, just execute the provided command exec "$@" esac diff --git a/README.md b/README.md index 67993281d..61f0065d3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +Disconnect this branch original Github repo. -- Vinay Khosla + About this Repo ======