mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
[Dockerfile] Fix creation of plugins.json with buildah (#1602)
Multi-line RUN instructions are unsupported by default docker (works with buildkit) and buildah, instead one has to use other tricks like ANSI-C quoting for the shell via \n\ and multiple echo commands. Includes a buildah github workflow to help ensure future compatibility.
This commit is contained in:
12
.github/workflows/docker-image.yml
vendored
12
.github/workflows/docker-image.yml
vendored
@@ -9,6 +9,18 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build-image-with-buildah:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
-
|
||||||
|
name: Build with buildah
|
||||||
|
run: buildah bud .
|
||||||
|
|
||||||
build-docker-image:
|
build-docker-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
31
Dockerfile
31
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
# syntax = docker/dockerfile:1.3-labs
|
# syntax = docker/dockerfile:1.0-experimental
|
||||||
ARG VAGRANT_VERSION=2.3.0
|
ARG VAGRANT_VERSION=2.3.0
|
||||||
|
|
||||||
|
|
||||||
@@ -38,8 +38,7 @@ FROM base as build
|
|||||||
# allow caching of packages for build
|
# allow caching of packages for build
|
||||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
||||||
RUN sed -i '/deb-src/s/^# //' /etc/apt/sources.list
|
RUN sed -i '/deb-src/s/^# //' /etc/apt/sources.list
|
||||||
RUN --mount=id=apt-cache-v1,type=cache,target=/var/cache/apt --mount=id=apt-lib-v1,type=cache,target=/var/lib/apt \
|
RUN apt update \
|
||||||
apt update \
|
|
||||||
&& apt build-dep -y \
|
&& apt build-dep -y \
|
||||||
vagrant \
|
vagrant \
|
||||||
ruby-libvirt \
|
ruby-libvirt \
|
||||||
@@ -61,20 +60,18 @@ RUN find /opt/vagrant/embedded/ -type f | grep -v /opt/vagrant/embedded/plugins.
|
|||||||
|
|
||||||
RUN /opt/vagrant/embedded/bin/gem install --install-dir /opt/vagrant/embedded/gems/${VAGRANT_VERSION} ./pkg/vagrant-libvirt*.gem
|
RUN /opt/vagrant/embedded/bin/gem install --install-dir /opt/vagrant/embedded/gems/${VAGRANT_VERSION} ./pkg/vagrant-libvirt*.gem
|
||||||
|
|
||||||
RUN cat <<EOF > /opt/vagrant/embedded/plugins.json
|
RUN echo -n '{\n\
|
||||||
{
|
"version": "1",\n\
|
||||||
"version": "1",
|
"installed": {\n\
|
||||||
"installed": {
|
"vagrant-libvirt": {\n\
|
||||||
"vagrant-libvirt": {
|
"ruby_version": "'$(/opt/vagrant/embedded/bin/ruby -e 'puts "#{RUBY_VERSION}"')'",\n\
|
||||||
"ruby_version":"$(/opt/vagrant/embedded/bin/ruby -e 'puts RUBY_VERSION')",
|
"vagrant_version": "'${VAGRANT_VERSION}'",\n\
|
||||||
"vagrant_version":"${VAGRANT_VERSION}",
|
"gem_version":"",\n\
|
||||||
"gem_version":"",
|
"require":"",\n\
|
||||||
"require":"",
|
"sources":[]\n\
|
||||||
"sources":[]
|
}\n\
|
||||||
}
|
}\n\
|
||||||
}
|
}' > /opt/vagrant/embedded/plugins.json
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
FROM build as pruned
|
FROM build as pruned
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user