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

Enable building Docker images for released packages #1495

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

amarthadan
Copy link
Contributor

Not really solving #1332 per se but rather a forgotten part of #1331. Also, some refactoring, clean up, and breaking into smaller parts that we can now build on 🙂

@amarthadan amarthadan requested a review from a team October 12, 2022 13:28
@amarthadan amarthadan self-assigned this Oct 12, 2022
Base automatically changed from temp-v0.10.0 to master October 13, 2022 14:16
Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

I tested this by building the images locally and testing them. I wanted to also use the local NPM packages but the current setup won't work on macOS due to this.

I tried publishing ports for both docker:scripts:npm-registry command and also to the verdaccio container run inside the docker, but it didn't help.

Otherwise code 👍 LGTM


## How it works
- Start/stop a local NPM registry Docker container
- Build and publish NPM packages to both local and official (TODO) NPM registry
Copy link
Contributor

Choose a reason for hiding this comment

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

intended todo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that one is intended, I'm working on that right now 🙂

package.json Outdated
"docker:build": "yarn docker:build:packaging && yarn docker:build:images",
"docker:build:images": "docker run --rm -v $(pwd):/airnode -v /var/run/docker.sock:/var/run/docker.sock api3/airnode-packaging:latest",
"docker:build:packaging": "docker build --tag api3/airnode-packaging:latest --file docker/Dockerfile docker/",
"docker:build:local": "yarn docker:build:packaging && yarn docker:build:images:local",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can you sort them alphabetically?

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 swear they were but I changed them so many times they got out of sync 😅 Will do.

@aquarat
Copy link
Contributor

aquarat commented Oct 14, 2022

I tested this by building the images locally and testing them. I wanted to also use the local NPM packages but the current setup won't work on macOS due to this.

MacOS's lack of containers is... sad. I know it's generally slower due to the FS mounts but I didn't realise it also had this network limitation, it makes sense.

@Siegrift
Copy link
Contributor

MacOS's lack of containers is... sad. I know it's generally slower due to the FS mounts but I didn't realise it also had this network limitation, it makes sense.

Actually, the fix is simple (just publish the ports) and together with @amarthadan we already fixed the issue.

"docker:scripts:build-docker-images": "docker run --rm -v /var/run/docker.sock:/var/run/docker.sock api3/airnode-packaging:latest build-docker-images",
"docker:scripts:build-docker-images:latest": "yarn docker:scripts:build-docker-images",
"docker:scripts:build-docker-images:local": "yarn docker:scripts:build-docker-images --npm-registry local --npm-tag local --docker-tag local",
"docker:scripts:npm-registry": "docker run --rm -v /var/run/docker.sock:/var/run/docker.sock api3/airnode-packaging:latest npm-registry",
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This always runs with the latest tag, but other script can be run with local and latest` tags.

@@ -38,7 +38,9 @@ export const stopNpmRegistry = () => {

export const startNpmRegistry = async () => {
const npmRegistryContainerName = `airnode-npm-registry-${randomBytes(4).toString('hex')}`;
runCommand(`docker run -d --rm --name ${npmRegistryContainerName} ${NPM_REGISTRY_CONTAINER_IMAGE}`);
runCommand(
`docker run -d --rm -p 127.0.0.1:${NPM_REGISTRY_CONTIANER_PORT}:${NPM_REGISTRY_CONTIANER_PORT} --name ${npmRegistryContainerName} ${NPM_REGISTRY_CONTAINER_IMAGE}`
Copy link
Contributor

Choose a reason for hiding this comment

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

change NPM_REGISTRY_CONTIANER_PORT to NPM_REGISTRY_CONTAINER_PORT

Also cleanup and modularization of packaging scripts.
Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@amarthadan amarthadan merged commit 685a70c into master Oct 26, 2022
@amarthadan amarthadan deleted the packaging-automation-cleanup branch October 26, 2022 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants