Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: add core22 base #4290

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 12 additions & 29 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
ARG RISK=edge
ARG UBUNTU=xenial
ARG RISK=stable
ARG UBUNTU=22.04
Copy link

@VladRassokhin VladRassokhin Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: In README.md codename of release is used, probably makes sense to stick to codenames and replace with jammy ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rarely remember which release name is which version. I remember that 22.04 is the latest LTS, and I guess that's just what matters here.


FROM ubuntu:$UBUNTU as builder
ARG RISK
ARG UBUNTU
RUN echo "Building snapcraft:$RISK in ubuntu:$UBUNTU"

# Grab dependencies
RUN apt-get update
RUN apt-get dist-upgrade --yes
RUN apt-get install --yes \
RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install \
curl \
jq \
squashfs-tools

# Grab the core snap (for backwards compatibility) 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/core' | jq '.download_url' -r) --output core.snap
RUN mkdir -p /snap/core
RUN unsquashfs -d /snap/core/current core.snap

# Grab the core18 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/core18' | jq '.download_url' -r) --output core18.snap
RUN mkdir -p /snap/core18
RUN unsquashfs -d /snap/core18/current core18.snap

# 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
# Download and unpack snap bases and snapcraft as a snap
COPY --chmod=755 prepare.sh .
RUN ./prepare.sh

# Fix Python3 installation: Make sure we use the interpreter from
# the snapcraft snap:
Expand All @@ -58,11 +36,16 @@ FROM ubuntu:$UBUNTU
COPY --from=builder /snap/core /snap/core
COPY --from=builder /snap/core18 /snap/core18
COPY --from=builder /snap/core20 /snap/core20
COPY --from=builder /snap/core20 /snap/core22
Copy link

@VladRassokhin VladRassokhin Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major: should be core22 in both args

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that. Thanks. Fixed.

COPY --from=builder /snap/snapcraft /snap/snapcraft
COPY --from=builder /snap/bin/snapcraft /snap/bin/snapcraft

# Generate locale and install dependencies.
RUN apt-get update && apt-get dist-upgrade --yes && apt-get install --yes snapd sudo locales && locale-gen en_US.UTF-8
RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: not sure whether this change is really necessary as it just changes the order of arguments and adds lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, following best practices is a good thing, but it's not mentioned in the commit message and looks unrelated (could be in another commit and PR)

snapd \
sudo \
locales \
&& locale-gen en_US.UTF-8

# Set the proper environment.
ENV LANG="en_US.UTF-8"
Expand Down
13 changes: 8 additions & 5 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Creating docker containers for snapcraft

By default the `Dockerfile` builds Ubuntu 16.04 (Xenial) image with `snapcraft` from the `edge` channel.
By default the `Dockerfile` builds Ubuntu 22.04 (Jellyfish) image with
`snapcraft` from the `stable` channel:

docker build . --no-cache

It is however possible to choose the base Ubuntu version and the Snapcraft channel (risk levels):
To choose different Ubuntu version and the Snapcraft channel (risk levels),
use use `--build-arg RISK=<risk>` and `--build-arg UBUNTU=<name>` options:

docker build . --no-cache --build-arg RISK=beta --build-arg UBUNTU=bionic

Possible RISK values:

- `edge`
- `beta`
- `candidate`
- `stable`

To do that, use `--build-arg RISK=<risk>` and `--build-arg UBUNTU=<name>` arguments:

docker build . --no-cache --build-arg RISK=beta --build-arg UBUNTU=bionic
24 changes: 24 additions & 0 deletions docker/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -xeo pipefail


echo "--- unpacking bases for snapcraft/$RISK ---"

# Grab the core snaps (which snapcraft uses as a base) from the stable channel
# and unpack them in the proper place.
BASES="core core18 core20 core22"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't make much sense to build a snap with a core18 base if the base of the OCI image is 22.04

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many snaps that need core18. Why it is wrong to build core18 with 22.04?

for base in $BASES; do
curl -L "$(curl -H "X-Ubuntu-Series: 16" "https://api.snapcraft.io/api/v1/snaps/details/$base" | jq ".download_url" -r)" --output "$base.snap"
mkdir -p "/snap/$base"
unsquashfs -d "/snap/$base/current" "$base.snap"
done


echo "--- unpacking snapcraft/$RISK ---"

# Grab the snapcraft snap from the $RISK channel and unpack it in the proper
# place.
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
mkdir -p /snap/snapcraft
unsquashfs -d /snap/snapcraft/current snapcraft.snap