vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.29k stars 908 forks source link

Docker images based on alpine linux #2988

Open fliiiix opened 1 year ago

fliiiix commented 1 year ago

Is your feature request related to a problem? Please describe. I can not use the official docker image to run my gitlab ci job.

I have a gitlab job which looks like this:

.matrix_template: &matrix_template
  matrix:
    - IMAGE: ubuntu-bionic-cloudinit
      URL: https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.ova
    - IMAGE: ubuntu-focal-cloudinit
      URL: https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.ova

variables:
  GOVC_URL: XXX
  GOVC_USERNAME:XXX
  GOVC_PASSWORD: ${VSPHERE_PASSWORD}
  GOVC_DATACENTER: XXX
  GOVC_DATASTORE: XXX
  GOVC_CLUSTER: XXX
  GOVC_RESOURCE_POOL: XXX
  GOVC_NETWORK: XXX
  GOVC_FOLDER:XXX
  GOVC_INSECURE: 'true'

 get-images:
   stage: download
   image: galaad991/govc:0.24.0
   parallel:
     <<: *matrix_template
   script:
    - echo "Downloading public image [${IMAGE}-${TAG}]"
    - govc vm.destroy ${IMAGE}-${TAG} || true
    - govc import.ova -name ${IMAGE}-${TAG} -folder vm/${GOVC_FOLDER} ${URL}
    - govc vm.markastemplate ${IMAGE}-${TAG}

This wont work with the minimal official docker image, because export and things like echo are not supported.

Describe the solution you'd like A image based on a minimal linux distro for example alpine would be great.

Describe alternatives you've considered The current way of providing environment is -e but I guess it is obvious from the example here that it does not scale.

Something like this:

script:
  - -e GOVC_URL=XXX -e GOVC_USERNAME=XXX -e GOVC_PASSWORD=${VSPHERE_PASSWORD} -e GOVC_DATACENTER=XXX -e GOVC_DATASTORE=XXX -e GOVC_CLUSTER=XXX -e GOVC_RESOURCE_POOL=XXX -e GOVC_NETWORK=XXX -e GOVC_FOLDER=XXX -e GOVC_INSECURE='true' vm.destroy ${IMAGE}-${TAG}
github-actions[bot] commented 1 year ago

Howdy 🖐   fliiiix ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Mark as fresh by adding the comment /remove-lifecycle stale.

fliiiix commented 1 year ago

/remove-lifecycle stale

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Mark as fresh by adding the comment /remove-lifecycle stale.

fliiiix commented 1 year ago

/remove-lifecycle stale

Fredouye commented 4 months ago

Hi

it would be very useful to have an Alpine based image, for GitLab CI pipelines for example (where a shell is required).

This Dockerfile :

FROM vmware/govc:v0.37.0 as govc

FROM alpine:3.19.1

COPY --from=govc /govc /bin/govc

RUN apk update && \
    apk upgrade

CMD ["/bin/sh"]

Results in a 25 Mb image, compared to the 15 Mb of vmware/govc image.

Could it be an option to keep the current image based on scratch, and add a govc-dev image based on Alpine ?

Thanks in advance.

fliiiix commented 4 months ago

I mean i always thought of it as an additional image and the thing im doing
https://github.com/fliiiix/govc-alpine/tree/main results in a https://hub.docker.com/layers/l33tname/govc-alpine/v0.37.0/images/sha256-4fa63e890f83c143dba05beaaaa641c7ecfe1106dd3a444a4a386c17678e4d68?context=repo ~17mb compressed image according to docker hub

but i would love that this would be just part of the official options

atc0005 commented 4 months ago
RUN apk update && \
    apk upgrade

This may be relevant:

Specifically:

The --no-cache option allows to not cache the index locally, which is useful for keeping containers small.

Literally it equals apk update in the beginning and rm -rf /var/cache/apk/* in the end.