Skip to content

Commit

Permalink
Simplify rock, make it bare based
Browse files Browse the repository at this point in the history
The rock is based on a single go binary, a whole ubuntu distribution is
unnecessary. Still, include coreutils_bins and bash_bins to simplify
debugging at run time.

Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
  • Loading branch information
gboutry committed Oct 2, 2024
1 parent d1c064f commit 4ca99ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
8 changes: 4 additions & 4 deletions rocks/consul/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ it will help ensure that all layers of the image are imported
into docker (this is just the top layer).

```bash
> skopeo --insecure-policy copy oci-archive:consul_v1.19.2_amd64.rock docker-daemon:consul:v1.19.2
> skopeo --insecure-policy copy oci-archive:consul_1.19.2_amd64.rock docker-daemon:consul:1.19.2
```

If you are interested in giving it a go in Microk8s, you can
export the image from your docker registry and then into the
microk8s registry:

```bash
> docker save consul:v1.19.2 > ./consul_v1.19.2.tar
> microk8s ctr image import ./consul_v1.19.2.tar
> docker save consul:1.19.2 > ./consul_1.19.2.tar
> microk8s ctr image import ./consul_1.19.2.tar
# Try with sunbeam
> juju attach-resource consul consul-image=consul:v1.19.2
> juju attach-resource consul consul-image=consul:1.19.2
```
49 changes: 21 additions & 28 deletions rocks/consul/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,42 @@ summary: Hashicorp Consul
license: Apache-2.0
description: |
Ubuntu distribution of Hashicorp Consul
version: 'v1.19.2'

# renovate: base: ubuntu:22.04@sha256:1b8d8ff4777f36f19bfe73ee4df61e3a0b789caeff29caa019539ec7c9a57f95
base: ubuntu@22.04
version: "1.19.2"
base: bare
build-base: ubuntu@24.04
platforms:
amd64:

package-repositories:
- type: apt
cloud: caracal
priority: always
run-user: _daemon_

services:
consul:
override: replace
command: consul
command: bin/consul agent
user: consul
group: consul

parts:
consul-user:
plugin: nil
overlay-script: |
groupadd --root $CRAFT_OVERLAY --gid 5996 --system consul
useradd \
--gid 5996 \
--uid 5996 \
--no-create-home \
--home /var/lib/consul \
--root $CRAFT_OVERLAY \
--system \
--shell /bin/false \
consul
override-prime: |
craftctl default
# Give permission and create the required directories
mkdir -p $CRAFT_PRIME/var/lib/consul
chown -R 5996:5996 $CRAFT_PRIME/var/lib/consul
mkdir -p $CRAFT_PRIME/etc || true
echo "consul:x:5996:" >> $CRAFT_PRIME/etc/group
echo "consul:x:5996:5996::/var/lib/consul:/usr/bin/false" >> $CRAFT_PRIME/etc/passwd
folders=(var/lib/consul etc/consul.d)
for folder in "${folders[@]}"; do
mkdir -p $CRAFT_PRIME/$folder || true
chown -R 5996:5996 $CRAFT_PRIME/$folder
done
snap-consul-client: # replace with consul snap once it is available
snap-consul-client:
after: [consul-user]
stage-packages:
# following are just for debug purposes
- bash_bins
- coreutils_bins
plugin: nil
stage-snaps:
- consul-client/latest/edge
override-prime: |
mkdir -p $CRAFT_PRIME/usr/local/bin
cp /root/parts/$CRAFT_PART_NAME/install/consul $CRAFT_PRIME/usr/local/bin/consul
- consul-client/latest/edge

0 comments on commit 4ca99ac

Please # to comment.