Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the sanity check for docker image #1793

Closed
git-hulk opened this issue Oct 6, 2023 · 2 comments · Fixed by #1877
Closed

Add the sanity check for docker image #1793

git-hulk opened this issue Oct 6, 2023 · 2 comments · Fixed by #1877
Labels
A-ci area ci good first issue Good for newcomers help wanted Good for newcomers

Comments

@git-hulk
Copy link
Member

git-hulk commented Oct 6, 2023

We'd better add some sanity checks in:

check-docker:
name: Check Docker image
needs: [precondition, check-and-lint, check-typos]
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Get core numbers
run: echo "NPROC=$(nproc)" >> $GITHUB_ENV
- uses: docker/build-push-action@v3
with:
context: .
build-args: MORE_BUILD_ARGS=-j${{ env.NPROC }}
push: false
tags: kvrocks:ci
outputs: type=docker
- name: Test built image
run: docker run --rm kvrocks:ci -v

Originally posted by @tisonkun in #1784 (comment)

As mentioned in the comments, we at least check if the docker listening port can be accessed from outside.

@git-hulk git-hulk added help wanted Good for newcomers good first issue Good for newcomers A-ci area ci labels Oct 6, 2023
@jyf111
Copy link
Contributor

jyf111 commented Nov 5, 2023

How about using the following commands? @git-hulk

id="$(docker run --rm -d -p 6666:6666 kvrocks:ci)"
sleep 1m # waiting for the periodic container health check

if [ "$(docker inspect --format='{{.State.Health.Status}}' $id)" != "healthy" ]; then
  echo "Container is not healthy."
  exit 1
fi

if [ "$(ss --listening --no-header --tcp '( sport = :6666 )')" == "" ]; then
  echo "The container listening port can not be accessed from outside."
  exit 1
fi

docker stop $id

@git-hulk
Copy link
Member Author

git-hulk commented Nov 5, 2023

@jyf111 Looks good, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ci area ci good first issue Good for newcomers help wanted Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants