-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: use ubuntu 20.04 for building snaps (#18)
- Loading branch information
1 parent
b4abb30
commit e6ebe16
Showing
3 changed files
with
79 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
ARG RISK=stable | ||
ARG REPO=mcr.microsoft.com/mirror/docker/library/ubuntu | ||
ARG TAG=20.04 | ||
|
||
FROM ${REPO}:${TAG} as builder | ||
ARG RISK | ||
ARG REPO | ||
ARG TAG | ||
RUN echo "Building snapcraft:$RISK in $REPO:$TAG" | ||
|
||
# Grab dependencies | ||
RUN apt-get update | ||
RUN apt-get dist-upgrade --yes | ||
RUN apt-get install --yes \ | ||
curl \ | ||
jq \ | ||
squashfs-tools \ | ||
git \ | ||
build-essential \ | ||
autoconf | ||
|
||
# Grab the core20 snap (which snapcraft uses as a base) from the stable channel | ||
# and unpack it in the proper place. | ||
RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core20' | jq '.download_url' -r) --output core20.snap | ||
RUN mkdir -p /snap/core20 | ||
RUN unsquashfs -d /snap/core20/current core20.snap | ||
|
||
# Grab the snapcraft snap from the $RISK channel and unpack it in the proper | ||
# place. | ||
RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel='$RISK | jq '.download_url' -r) --output snapcraft.snap | ||
RUN mkdir -p /snap/snapcraft | ||
RUN unsquashfs -d /snap/snapcraft/current snapcraft.snap | ||
|
||
# Fix Python3 installation: Make sure we use the interpreter from | ||
# the snapcraft snap: | ||
RUN unlink /snap/snapcraft/current/usr/bin/python3 | ||
RUN ln -s /snap/snapcraft/current/usr/bin/python3.* /snap/snapcraft/current/usr/bin/python3 | ||
RUN echo /snap/snapcraft/current/lib/python3.*/site-packages >> /snap/snapcraft/current/usr/lib/python3/dist-packages/site-packages.pth | ||
RUN /snap/snapcraft/current/usr/bin/python3 /snap/snapcraft/current/usr/bin/pip3 install -U setuptools | ||
|
||
# Create a snapcraft runner (TODO: move version detection to the core of | ||
# snapcraft). | ||
RUN mkdir -p /snap/bin | ||
RUN echo "#!/bin/sh" > /snap/bin/snapcraft | ||
RUN snap_version="$(awk '/^version:/{print $2}' /snap/snapcraft/current/meta/snap.yaml | tr -d \')" && echo "export SNAP_VERSION=\"$snap_version\"" >> /snap/bin/snapcraft | ||
RUN echo 'exec "$SNAP/usr/bin/python3" "$SNAP/bin/snapcraft" "$@"' >> /snap/bin/snapcraft | ||
RUN chmod +x /snap/bin/snapcraft | ||
|
||
# Build patchelf | ||
RUN git clone https:/NixOS/patchelf | ||
RUN cd patchelf && ./bootstrap.sh && ./configure && make && make check && cp ./src/patchelf /snap/bin/patchelf | ||
|
||
# Multi-stage build, only need the snaps from the builder. Copy them one at a | ||
# time so they can be cached. | ||
FROM ${REPO}:${TAG} | ||
COPY --from=builder /snap/core20 /snap/core20 | ||
COPY --from=builder /snap/snapcraft /snap/snapcraft | ||
COPY --from=builder /snap/bin/snapcraft /snap/bin/snapcraft | ||
COPY --from=builder /snap/bin/patchelf /snap/bin/patchelf | ||
|
||
# Generate locale and install dependencies. | ||
RUN apt-get update && apt-get install --yes snapd sudo locales && locale-gen en_US.UTF-8 | ||
|
||
# Set the proper environment. | ||
ENV LANG="en_US.UTF-8" | ||
ENV LANGUAGE="en_US:en" | ||
ENV LC_ALL="en_US.UTF-8" | ||
ENV SNAP="/snap/snapcraft/current" | ||
ENV SNAP_NAME="snapcraft" | ||
ENV SNAP_ARCH="amd64" | ||
ENV PATH="/snap/bin:/snap/snapcraft/current/usr/bin:$PATH" |