mirror of
https://github.com/kairos-io/osbuilder.git
synced 2025-08-16 14:57:31 +00:00
Don't assume /bin/sh is there in the base image
In other words, don't run `RUN` commands that might not be there. Ideally all `RUN` commands should run on the builder stage and at the final step, we just copy everything over. Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
791b780cd2
commit
2f0d06b835
@ -10,12 +10,12 @@ import (
|
|||||||
// the root command.
|
// the root command.
|
||||||
func NewConvertCmd() *cobra.Command {
|
func NewConvertCmd() *cobra.Command {
|
||||||
c := &cobra.Command{
|
c := &cobra.Command{
|
||||||
Use: "convert rootfs",
|
Use: "convert /path/to/rootfs /path/to/result image_name",
|
||||||
Short: "Convert a base image to a Kairos image",
|
Short: "Convert a base image to a Kairos image",
|
||||||
Long: "Convert a base image to a Kairos image\n\n" +
|
Long: "Convert a base image to a Kairos image\n\n" +
|
||||||
"This is best effort. Enki will try to detect the distribution and add\n" +
|
"This is best effort. Enki will try to detect the distribution and add\n" +
|
||||||
"the necessary bits to convert it to a Kairos image",
|
"the necessary bits to convert it to a Kairos image",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(3),
|
||||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return CheckRoot() // TODO: Do we need root?
|
return CheckRoot() // TODO: Do we need root?
|
||||||
},
|
},
|
||||||
|
@ -84,14 +84,19 @@ func (ca *ConverterAction) createDockerfile() (string, error) {
|
|||||||
|
|
||||||
// write data to the temporary file
|
// write data to the temporary file
|
||||||
data := []byte(`
|
data := []byte(`
|
||||||
|
FROM busybox as builder
|
||||||
|
RUN mkdir /rootfs
|
||||||
|
COPY . /rootfs/.
|
||||||
|
|
||||||
|
RUN echo "nameserver 8.8.8.8" > /rootfs/etc/resolv.conf
|
||||||
|
RUN cat /rootfs/etc/resolv.conf
|
||||||
|
|
||||||
FROM scratch as rootfs
|
FROM scratch as rootfs
|
||||||
COPY . .
|
|
||||||
|
COPY --from=builder /rootfs/ .
|
||||||
|
|
||||||
FROM rootfs
|
FROM rootfs
|
||||||
|
|
||||||
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf
|
|
||||||
RUN cat /etc/resolv.conf
|
|
||||||
|
|
||||||
# TODO: Do more clever things
|
# TODO: Do more clever things
|
||||||
RUN apt-get update && apt-get install -y curl
|
RUN apt-get update && apt-get install -y curl
|
||||||
`)
|
`)
|
||||||
@ -136,6 +141,7 @@ func (ca *ConverterAction) removeDockerIgnore() error {
|
|||||||
func (ca *ConverterAction) BuildWithKaniko(dockerfile, resultPath string) (string, error) {
|
func (ca *ConverterAction) BuildWithKaniko(dockerfile, resultPath string) (string, error) {
|
||||||
d, err := ca.Runner.Run(
|
d, err := ca.Runner.Run(
|
||||||
"executor",
|
"executor",
|
||||||
|
//"--verbosity", "debug",
|
||||||
"--dockerfile", dockerfile,
|
"--dockerfile", dockerfile,
|
||||||
"--context", ca.rootFSPath,
|
"--context", ca.rootFSPath,
|
||||||
"--destination", ca.imageName, // This is the name of the image when you: cat image.tar | docker load
|
"--destination", ca.imageName, // This is the name of the image when you: cat image.tar | docker load
|
||||||
|
Loading…
Reference in New Issue
Block a user