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

fix: update Dockerfile with python and .gyp to support install and run of Glee project in container #1208

Merged
merged 17 commits into from
Mar 29, 2024

Conversation

eelcofolkertsma
Copy link
Contributor

Add python and .gyp to support install and run of Glee project in container

In follow up to #1207 bug

Glee install fails over python. I have followed best practice for Node images to patch Dockerfile with apk for python, .gyp and related stuff

Related issue(s)
Fixes #1207

Add python and .gyp to support install and run of Glee project in container
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@eelcofolkertsma eelcofolkertsma changed the title Update Dockerfile with python and .gyp to support install and run of Glee project in container Fix: update Dockerfile with python and .gyp to support install and run of Glee project in container Mar 1, 2024
@eelcofolkertsma eelcofolkertsma changed the title Fix: update Dockerfile with python and .gyp to support install and run of Glee project in container fix: update Dockerfile with python and .gyp to support install and run of Glee project in container Mar 1, 2024
@eelcofolkertsma eelcofolkertsma marked this pull request as draft March 6, 2024 15:01
@eelcofolkertsma
Copy link
Contributor Author

I have developed an alternative solution to establish a container with running Glee server. The change to Dockerfile has been undone. Instead I have added a file composeGlee.yaml for invocation with 'docker compose -f composeGlee.yaml up'

Docker Compose

  • takes current image of asyncapi/cli from DockerHub,
  • adds pyhton and .gyp,
  • creates and installs new glee project
  • attaches to directories on local system (here you can update or prepare Glee files. Local contents override what comes from image )
  • npm run dev to deploy a server conform the Glee files

Known deficiency: permissions on new glee project are "root" write only. I have solved with chown on my own machine but this can be done more nicely

@eelcofolkertsma eelcofolkertsma marked this pull request as ready for review March 6, 2024 15:36
@eelcofolkertsma
Copy link
Contributor Author

In consultation with Lukasz

  • Base image upgraded to node:20-alpine from node:16-alpine (in Dockerfile)
  • Install of python and .gyp added to build of asyncapi/cli image (in Dockerfile)
  • add comment with manual build instruction for local image (in Dockerfile)
  • add comment to use docker compose up for testing of local image (in Dockerfile)
  • add compose.yaml to launch running container with studio from local image for testing
  • Remove compose file to launch Glee server as too specific a use case

Running container supports studio and start of glee server. This was tested with docker exec -it

Note: .github/workflows folder contains a flow to publish docker image to Docker hub on new release. Rather confusing this workflow speaks about an Ubuntu image. I have no experience in workflows so I cannot track the error
Note 2: asyncapi start studio requires presence of an asyncapi.yaml file (otherwise start breaks on error). But funny enough the file contents are not displayed in running studio, and the file can have any content. Life would be much easier if check on syncapi.yaml is removed from studio code!!!

Dockerfile Show resolved Hide resolved
compose.yaml Outdated
@@ -0,0 +1,16 @@
version: '3'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need a compose.yaml committed in the repo.
If it's needed I suggest to rename it to docker-compose.yaml
To be confirmed by current maintainers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do use the file in testing the viability of docker container (studio, glee), but test is far from trivial. I am very open to other test approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has been renamed as per suggestion and moved to location ./test/manual
Comment in Dockerfile has been adjusted accordingly (instructions for testing)

Dockerfile Show resolved Hide resolved
@@ -0,0 +1,16 @@
version: '3'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you think it is needed to keep in the repo if in the end it is not used in any automated tests? what is the value of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems current image is not tested at all, not automated nor manual. Example: the ARG for cli version that I removed as dysfunctional. I guess that behavior has been around for many months.
Than a manual test is better than nothing.
I lack skill to develop an automated test for the image, but fine with me to drop the manual test resource and raise an issue to validate the docker image in some automated way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the ARG... I have pulled image from DockerHub and inspected version of asyncapi in resulting container. The ARG is ignored in building of image! Current version is 1 something, not 0.59 as requested per ARG. And this is good.
I can see value to manually install an older (trusted) version of CLI, but for the image you would expect latest and greatest version. Docker Hub has the older versions as well as in docker pull asyncapi/cli:1.6.14

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you're right, we missed it and did not add a simple docker build testing - lemme fix that, we have some generic workflows that I can pull in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so automated tests are in place now

next

yes, we know the arg is ignored (overwritten) in release: https://github.com/asyncapi/cli/blob/master/.github/workflows/release-docker.yml#L42 so we always want to release a latest

the arg in docker file was added for a reason -> see the story in #675

does it explain all?
maybe instead of removing ARG ASYNCAPI_CLI_VERSION=0.59.1 we should add a comment for future, linking to the other PR I pointed out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You predict my thoughts. The ARG goes back in with comment that it is for manual image create only, github workflow overrides. #675 has lots of insider communication, perhaps a bit too much ;-)

@eelcofolkertsma
Copy link
Contributor Author

Hi Lukasz, all is in place now: automated test on Docker image, python and .gyp in Docker image, and node:20

For your approval

Dockerfile Outdated
rm -rf /var/lib/apt/lists/* && \
rm /var/cache/apk/*

# Installing latest released npm package
RUN npm install --ignore-scripts -g @asyncapi/cli@"$ASYNCAPI_CLI_VERSION"
RUN npm install --ignore-scripts -g @asyncapi/cli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eelcofolkertsma you added ASYNCAPI_CLI_VERSION back in line 4 but it is still missing here - basically not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fixed that one too
If you use Dockerfile without change you get latest version of cli. If you add a version-value you get image for that version of cli
Tested OK in Github codespaces (default version=1.7.3, forced version=1.7.2) with docker build -t cli . and docker run cli --version

Copy link

sonarcloud bot commented Mar 27, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks 🚀

@derberg
Copy link
Member

derberg commented Mar 29, 2024

/rtm

@asyncapi-bot asyncapi-bot merged commit f0bdcc2 into asyncapi:master Mar 29, 2024
11 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 1.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker image fails to support Glee
4 participants