Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
52e31c07
Commit
52e31c07
authored
Dec 01, 2017
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-oci: support skopeo layer caching
This requires skopeo version 0.1.25 Signed-off-by:
Felix Abecassis
<
fabecassis@nvidia.com
>
parent
0fd2b679
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
14 deletions
+33
-14
lxc-oci.in
templates/lxc-oci.in
+33
-14
No files found.
templates/lxc-oci.in
View file @
52e31c07
...
...
@@ -34,6 +34,7 @@ for bin in skopeo umoci jq; do
fi
done
LOCALSTATEDIR
=
"@LOCALSTATEDIR@"
LXC_TEMPLATE_CONFIG
=
"@LXCTEMPLATECONFIG@"
# Some useful functions
...
...
@@ -145,7 +146,7 @@ EOF
return
0
}
options
=
$(
getopt
-o
u:h
-l
help
,url:,username:,password:,
\
options
=
$(
getopt
-o
u:h
-l
help
,url:,username:,password:,
no-cache,
\
name:,path:,rootfs:,mapped-uid:,mapped-gid:
--
"
$@
"
)
if
[
$?
-ne
0
]
;
then
...
...
@@ -157,6 +158,7 @@ eval set -- "$options"
OCI_URL
=
""
OCI_USERNAME
=
OCI_PASSWORD
=
OCI_USE_CACHE
=
"true"
LXC_MAPPED_GID
=
LXC_MAPPED_UID
=
...
...
@@ -170,6 +172,7 @@ while :; do
-u
|
--url
)
OCI_URL
=
$2
;
shift
2
;;
--username
)
OCI_USERNAME
=
$2
;
shift
2
;;
--password
)
OCI_PASSWORD
=
$2
;
shift
2
;;
--no-cache
)
OCI_USE_CACHE
=
"false"
;
shift
1
;;
--name
)
LXC_NAME
=
$2
;
shift
2
;;
--path
)
LXC_PATH
=
$2
;
shift
2
;;
--rootfs
)
LXC_ROOTFS
=
$2
;
shift
2
;;
...
...
@@ -195,33 +198,43 @@ if [ -n "$OCI_PASSWORD" ] && [ -z "$OCI_USERNAME" ]; then
exit
1
fi
if
[
"
${
OCI_USE_CACHE
}
"
=
"true"
]
;
then
if
!
skopeo copy
--help
|
grep
-q
'dest-shared-blob-dir'
;
then
echo
"INFO: skopeo doesn't support blob caching"
OCI_USE_CACHE
=
"false"
fi
fi
USERNS
=
$(
in_userns
)
if
[
"
$USERNS
"
!=
"no"
]
;
then
if
[
"
$USERNS
"
=
"yes"
]
;
then
if
[
-z
"
$LXC_MAPPED_UID
"
]
||
[
"
$LXC_MAPPED_UID
"
=
"-1"
]
;
then
echo
"ERROR: In a user namespace without a map."
1>&2
exit
1
fi
fi
if
[
"
${
OCI_USE_CACHE
}
"
=
"true"
]
;
then
if
[
"
$USERNS
"
=
"yes"
]
;
then
if
[
-z
"
$LXC_MAPPED_UID
"
]
||
[
"
$LXC_MAPPED_UID
"
=
"-1"
]
;
then
echo
"ERROR: In a user namespace without a map."
1>&2
exit
1
fi
DOWNLOAD_MODE
=
"user"
DOWNLOAD_TARGET
=
"user"
DOWNLOAD_BASE
=
"
${
HOME
}
/.cache/lxc"
else
DOWNLOAD_MODE
=
"user"
DOWNLOAD_TARGET
=
"system"
DOWNLOAD_BASE
=
"
${
LOCALSTATEDIR
}
/cache/lxc"
fi
else
DOWNLOAD_BASE
=
/tmp
fi
# Trap all exit signals
trap
cleanup EXIT HUP INT TERM
if
!
type mktemp
>
/dev/null 2>&1
;
then
DOWNLOAD_TEMP
=
/tmp/lxc-oci.
$$
DOWNLOAD_TEMP
=
"
${
DOWNLOAD_BASE
}
/lxc-oci.
$$
"
mkdir
-p
$DOWNLOAD_TEMP
else
DOWNLOAD_TEMP
=
$(
mktemp
-d
)
DOWNLOAD_TEMP
=
$(
mktemp
-d
-p
"
${
DOWNLOAD_BASE
}
"
)
fi
# Download the image
- TODO - cache
# Download the image
skopeo_args
=(
""
)
if
[
-n
"
$OCI_USERNAME
"
]
;
then
CREDENTIALS
=
"
${
OCI_USERNAME
}
"
...
...
@@ -230,7 +243,13 @@ if [ -n "$OCI_USERNAME" ]; then
fi
skopeo_args+
=(
--src-creds
"
${
CREDENTIALS
}
"
)
fi
skopeo copy
${
skopeo_args
[@]
}
"
${
OCI_URL
}
"
"oci:
${
DOWNLOAD_TEMP
}
:latest"
if
[
"
${
OCI_USE_CACHE
}
"
=
"true"
]
;
then
skopeo_args+
=(
--dest-shared-blob-dir
"
${
DOWNLOAD_BASE
}
"
)
skopeo copy
${
skopeo_args
[@]
}
"
${
OCI_URL
}
"
"oci:
${
DOWNLOAD_TEMP
}
:latest"
ln
-s
"
${
DOWNLOAD_BASE
}
/sha256"
"
${
DOWNLOAD_TEMP
}
/blobs/sha256"
else
skopeo copy
${
skopeo_args
[@]
}
"
${
OCI_URL
}
"
"oci:
${
DOWNLOAD_TEMP
}
:latest"
fi
echo
"Unpacking the rootfs"
umoci_args
=(
""
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment