Skip to content

Instantly share code, notes, and snippets.

@oglok
Created December 20, 2023 15:01
Show Gist options
  • Save oglok/8ac0718c0dbd434b724d216c2ea8aef3 to your computer and use it in GitHub Desktop.
Save oglok/8ac0718c0dbd434b724d216c2ea8aef3 to your computer and use it in GitHub Desktop.
FROM quay.io/centos-bootc/fedora-bootc:eln
COPY rpmbuild/RPMS/x86_64/flightctl-agent-0.0.1-1.el9.x86_64.rpm /tmp/
COPY flightctl_rsa.pub /usr/etc-system/root.keys
RUN touch /etc/ssh/sshd_config.d/30-auth-system.conf; \
mkdir -p /usr/etc-system/; \
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf; \
chmod 0600 /usr/etc-system/root.keys
VOLUME /var/roothome
COPY .flightctl/config.yaml /etc/flightctl/
COPY .flightctl/certs/ca.crt /etc/flightctl
COPY .flightctl/certs/client-enrollment.* /etc/flightctl/
RUN rpm-ostree install -y /tmp/flightctl-agent-0.0.1-1.el9.x86_64.rpm
RUN ln -s /usr/lib/systemd/system/flightctl-agent.service /etc/systemd/system/multi-user.target.wants/
RUN ln -s /usr/lib/systemd/system/podman.service /etc/systemd/system/multi-user.target.wants/
RUN systemctl enable podman.service && \
systemctl enable flightctl-agent.service && \
ostree container commit
@cgwalters
Copy link

RUN ln -s /usr/lib/systemd/system/flightctl-agent.service /etc/systemd/system/multi-user.target.wants/

https://github.com/coreos/layering-examples/blob/5755f366c7d163cead6253211a726b760577a5cd/inject-go-binary/Containerfile#L13
is a better best practice for static systemd units right now; notably it puts the enablement under /usr and not /etc.

That said I think what you're doing here should still work...what result are you seeing? Is the service just not starting on boot?

RUN ln -s /usr/lib/systemd/system/podman.service /etc/systemd/system/multi-user.target.wants/

I think you should enable podman.socket instead...the service is activated by the socket.

@oglok
Copy link
Author

oglok commented Dec 20, 2023

Thanks for the tip @cgwalters. I was suspecting a problem with /etc and ostree. Let me try the symlink to /usr anyways.

Yes, after building the container image, I convert it to qcow2 using the image-builder-bootc project, and both services (podman and flightctl-agent which is my own app) are disabled on boot. Let me report back in a bit!

@oglok
Copy link
Author

oglok commented Dec 20, 2023

ok, symlinks to /usr/lib seem to work now. Thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment