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 support for PowerShell #653

Open
lamw opened this issue Feb 8, 2022 · 13 comments
Open

Add support for PowerShell #653

lamw opened this issue Feb 8, 2022 · 13 comments
Labels
enhancement A new feature or request

Comments

@lamw
Copy link

lamw commented Feb 8, 2022

What were you attempting to do?

To replace our current PowerShell Dockerfile(s) and build process using the new Buildpacks for .NET Core

The use case is for our Infrastructure Event-Driven Automation OSS project called the VMware Event Broker Appliance (VEBA). Users can define a "function" (code) across a number of programming/scripting languages which are then packaged up inside of a container image.

For our PowerShell users, we currently have two container templates:

  • Dockerfile.ps - Which represents the primary PowerShell runtime that all function derive from (at least from an example point of view)
  • Dockerfile.pcli - Which represents the primary VMware PowerCLI module that uses the PS runtime image and is the basis for all of our example functions when needing the PowerCLI module

From these two template images, we have a number of PowerShell and PowerCLI functions that users can quickly and easily use and add their respective PowerShell or PowerCLI code. From that, they can then build a container image that contains their unique function while leveraging the infrastructure that we've built as part of the two base container images, mentioned above.

Ultimately, our goal is to make it easy for our end users to write the minimal amount of PowerShell or PowerCLI code and be able to easily build a container image w/o needing to know about the underlying system that produces the image. Today, users must be a bit versed in constructing the Dockerfile (if they wish to introduce new dependencies/modules) and how it connects to their code (business value)

What did you expect to happen?

Easily convert our existing Dockerfile into respective buildpack configuration with good examples that we can follow to migrate away from using docker to pack to build our container images.

What was the actual behavior? Please provide log output, if possible.

Although the recently released .NET Core Buildpack enables the possibility for supporting PowerShell Core, my understanding is additional code enhancement is required to buildpack to enable our use case and is currently not feasible as an end consumer

Build Configuration

What platform (pack, kpack, tekton buildpacks plugin, etc.) are you using? Please include a version.

pack (0.23.0+git-0db2c77.build-3056) and looking to build PowerShell Core Container Images

What buildpacks are you using? Please include versions.

.NET Core

What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

N/A

Can you provide a sample app or relevant configuration (buildpack.yml,
nginx.conf, etc.)?

See above for details

@sophiewigmore sophiewigmore added the enhancement A new feature or request label Feb 9, 2022
@fg-j
Copy link

fg-j commented Mar 3, 2022

Hi @lamw. I took a look at the example Dockerfiles you provided. I think it would be possible for a buildpack to install PowerShell, and I'd be interested to hear from other users who would benefit from this.

However, I also noticed that your Dockerfiles are based on PhotonOS. Currently, Paketo buildpacks are currently only compatible with Ubuntu Bionic

@paketo-buildpacks/stacks-maintainers do you have any more context around PhotonOS and buildpacks' compatibility?

@lamw
Copy link
Author

lamw commented Mar 3, 2022

@fg-j We definitely would have users who would use this as they currently consume our PowerShell images

In theory, we should be able to also use Ubuntu but we chose Photon as thats our base-linux OS. Let me see if I can quickly put one together based on the original example but using Ubuntu Bionic and see if that helps

Our goal would be to use PhotonOS (which is an RPM-based system) for our base image

@lamw
Copy link
Author

lamw commented Mar 4, 2022

@fg-j Here's quick Dockerfile I've just put together using Ubuntu https://gist.github.com/lamw/bda4820e33532319423e6669c73af905

I was having some client issues (not sure why I can't pull from dockerhub but if you're able to, you should be able to simply replace the version of Ubuntu)

@sophiewigmore
Copy link
Member

Stacks maintainer here... I don't know much about the Photon OS but from my preliminary checks, it's a minimal Linux OS. I haven't dug into what's installed or not but if it's minimal I'm not sure if the .NET Core buildpacks would work on it. We'd have to do some investigation probably to see if the buildpacks/dependencies would "just work"

@lamw
Copy link
Author

lamw commented May 12, 2022

Hi @sophiewigmore - Would you have any updates on this or something I could help test or validate?

@fg-j
Copy link

fg-j commented May 12, 2022

Hey @lamw. Here's something that may be of interest to you: Paketo's jam CLI has added a jam create-stack command that will produce a CNB stack given a stack.toml stack descriptor and some Dockerfiles.

You could use this tool to create a Photon-based stack and test it against the existing Paketo buildpacks. This would be a great starting point for understanding the current buildpacks' interoperability with other stacks

If you find incompatibilities, please file issues! Paketo is interested in making buildpacks more stack-agnostic when possible.

@lamw
Copy link
Author

lamw commented May 12, 2022

@fg-j

Just gave jam a try on MacOS with the following but it throws error:

jam create-stack --config stack.toml --build-output build.oci --run-output run.oci
Building photon-powershell
  Building on linux/amd64
    Building base images
ERRO[0000] Tar: Can't stat file /Users/lamw to tar: open /Users/lamw/.Trash: operation not permitted
ERRO[0000] Tar: Can't stat file /Users/lamw to tar: open /Users/lamw/.Trash: operation not permitted

I'm using our Dockerfile based on Photon and here's stack.toml config:

id = "photon-powershell"
homepage = "https://williamlam.com"
maintainer = "William Lam"

platforms = ["linux/amd64"]

[build]
  dockerfile = "Dockerfile.ps"
  description = "PowerShell Base Image"

  uid = 1001
  gid = 1000

[run]
  dockerfile = "Dockerfile.ps"
  description = "PowerShell Base Image"

  uid = 1002
  gid = 1000

@fg-j
Copy link

fg-j commented May 13, 2022

@lamw What's pwd where you're running jam create-stack from?

@lamw
Copy link
Author

lamw commented May 13, 2022

@fg-j I'm running this in my home directory on my MacOS system /Users/lamw

@fg-j
Copy link

fg-j commented May 13, 2022

That may be the source of your problem. The jam create-stack command attempts to package up the entire current working directory as the "build context" for use in a Docker build. Try creating a subdirectory with your stack descriptor and relevant Dockerfiles. Then run the command from inside the subdirectory.

@lamw
Copy link
Author

lamw commented May 13, 2022

@fg-j Ah, that worked

It ran for ~10min or so but then it failed:

❯ jam create-stack --config stack.toml --build-output build.oci --run-output run.oci
Building photon-powershell
  Building on linux/amd64
    Building base images
      Build complete for base images
    build: Decorating base image
      Adding CNB_* environment variables
      Adding io.buildpacks.stack.* labels
      Creating cnb user
    run: Decorating base image
      Adding io.buildpacks.stack.* labels
      Creating cnb user
    build: Updating image
    run: Updating image
Error: Error: No such image: paketo.io/stack/87zgdlj0a5
Usage:
  jam create-stack [flags]

Flags:
      --build-output string   path to output the build image OCI archive (required)
      --config string         path to a stack descriptor file (required)
  -h, --help                  help for create-stack
      --run-output string     path to output the run image OCI archive (required)
      --secret strings        secret to be passed to your Dockerfile

failed to execute: Error: No such image: paketo.io/stack/87zgdlj0a5

@sophiewigmore
Copy link
Member

sophiewigmore commented May 16, 2022

@lamw I was able to reproduce the same error you're seeing on my Mac. I think we should file a separate issue at https://github.com/paketo-buildpacks/jam to track this bug, we need to investigate further. I can do that

@sophiewigmore
Copy link
Member

@lamw Hey, I'm working on a fix for this, but in the meantime a workaround is to use different Dockerfiles for build and run image creation. The change can be as small as just a null RUN echo hi, but the Dockerfiles need to produce different image SHAs to get around the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or request
Projects
None yet
Development

No branches or pull requests

3 participants