Run Spring Shell Command after starte Docker Image

138 Views Asked by At

I use a Github Action to start a Spring Boot image on a vServer. This Spring Boot application contains the Spring Shell Component and I can run my init-users command.

When I start the image locally or manually on the vServer, the shell is available.

$ docker run -it -p 8082:8080 repo/my-api
$ ...
$ shell:>

The following is an example of the docker commads in the GitHub Action.

script: |
    docker stop $(docker container ls  | grep 'repo/my-api' | awk '{print $1}')
    docker run -it -p 8002:8080 8080 repo/my-api:1.2.3
    # call init-users ?

How can the call to run init-users after starting the image look like?

It is not an option to define the shell command in the Dockerfile because I only want to run init-users during deployment.

1

There are 1 best solutions below

0
Richard Rublev On

You should familirize yourself with Github Actions components

Try to understand steps. A step is an individual task that can run commands in a job Example with bash

steps:
  - name: Display the path
    run: echo $PATH
    shell: bash