hrach
hrach

Reputation: 2492

Run command in Container for Linux during Azure Devops Pipeline Release

Currently I'm deploying my docker image into AppService for Linux from AzureDevops. I want to run some migrations before the container became fully available.

The db migrations are executed by calling a cli command in my container. How can I achieve this from DevOps pipeline?

  1. Is there a way to SSH to the specific not fully deployed container?
  2. Is there a way run a cli command without configuring SSH?
  3. Is there any other recommended way for migrations/running some scripts before making the container available?

Upvotes: 1

Views: 1313

Answers (2)

4c74356b41
4c74356b41

Reputation: 72171

I suppose you have 2 options:

  1. run some sort of init script that does the migrations and then starts the web server\what have you process that's actually doing the work
  2. modifying entrypoint\command that the container runs by default, so it does that on its own (dockerfile reference).

something like this:

RUN /bin/bash -c 'run migrations; run payload'

Upvotes: 1

trejjam
trejjam

Reputation: 21

We achieved this by modification of container entrypoint. We do not care much about the execution of migration from multiple containers simultaneously, it is handled by the migration framework.

#!/bin/bash

set -e

if [[ -n $MIGRATION_ONSTART ]]; then
    ( su -s /bin/bash -c "/var/www/bin/console migration:continue" www-data &)
fi

exec "$@"

Upvotes: 1

Related Questions