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 --disable-docker-image-update plugin flag #311

Merged

Conversation

florentmorin
Copy link
Contributor

The --disable-docker-image-update plugin flag has be added to allow use of local docker images.

Motivation:

Sometimes, you need to use a customized local docker image (ie. you want to use AWS SDK for Swift and OpenSSL is required). In this case, docker pull mustn't to be called.

Until now, the plugin automatically called docker pull to update Docker image. With the new flag, Docker image update can be disabled.

Modifications:

  • add --disable-docker-image-update plugin flag to disable docker pull call

Result:

I have a local docker image based on Swift 5.9.1 + Amazon Linux 2 and including OpenSSL.

FROM swift:5.9.1-amazonlinux2

# Install OpenSSL
RUN yum -y update && yum install -y \
    openssl \
    openssl-devel

I have build it with this command:

docker build -t swift-with-openssl .

Now, it's time to archive. Here are the results with or without the new flag.

Without flag:

😭 It fails with an error.

swift package archive --output-path /my/output/path --disable-sandbox --base-docker-image swift-with-openssl
# ...
-------------------------------------------------------------------------
building "my-awesome-lambda" in docker
-------------------------------------------------------------------------
updating "swift-with-openssl" docker image
  Using default tag: latest
  Error response from daemon: pull access denied for swift-with-openssl, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
error: /usr/local/bin/docker pull swift-with-openssl failed with code 1

With flag:

😁 Everything works as expected.

swift package archive --output-path /my/output/path --disable-sandbox --base-docker-image swift-with-openssl --disable-docker-image-update
# ...
-------------------------------------------------------------------------
building "my-awesome-lambda" in docker
-------------------------------------------------------------------------
building "MyAwesomeLambda"
  [0/1] Planning build
  Building for production...
# ...
  Build complete! (145.13s)
-------------------------------------------------------------------------
archiving "MyAwesomeLambda"
-------------------------------------------------------------------------
1 archive created
  * MyAwesomeLambda at /my/output/path/MyAwesomeLambda/MyAwesomeLambda.zip

motivation: sometimes, you need to use a customized local docker image and `docker pull` don’t have to be called

changes:
* add `--disable-docker-image-update` plugin flag to disable `docker pull` call
Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

thank you!

@tomerd tomerd enabled auto-merge (squash) December 1, 2023 19:22
@tomerd
Copy link
Contributor

tomerd commented Dec 1, 2023

@swift-server-bot test this please

@tomerd tomerd merged commit 2c3b245 into swift-server:main Dec 1, 2023
6 of 8 checks passed
@florentmorin florentmorin deleted the plugin-disable-docker-image-update branch December 1, 2023 21:33
@florentmorin florentmorin restored the plugin-disable-docker-image-update branch December 1, 2023 21:41
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.

2 participants