feat: add etcd build
- create rpm for etcd, etcdctl and etcdutl - manage systemd service for etcd
This commit is contained in:
parent
80d648ee95
commit
c7b8fb9fb5
1
rpms/etcd/3.5.18/release
Normal file
1
rpms/etcd/3.5.18/release
Normal file
@ -0,0 +1 @@
|
||||
1
|
||||
25
rpms/etcd/Dockerfile
Normal file
25
rpms/etcd/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
# Start with the AlmaLinux 8.10 base image
|
||||
FROM git.query.consul/unkin/almalinux8-rpmbuilder:latest
|
||||
|
||||
# Create output directory for RPMs
|
||||
RUN mkdir -p /app/dist
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
ARG PACKAGE_RELEASE
|
||||
ENV PACKAGE_RELEASE=${PACKAGE_RELEASE}
|
||||
ARG PACKAGE_VERSION
|
||||
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
|
||||
|
||||
# Copy nfpm.yaml from the context into the container
|
||||
COPY nfpm.yaml /app/nfpm.yaml
|
||||
COPY resources /app/resources
|
||||
|
||||
# Download the required files
|
||||
RUN wget -O /app/etcd-v${PACKAGE_VERSION}-linux-amd64.tar.gz https://github.com/etcd-io/etcd/releases/download/v${PACKAGE_VERSION}/etcd-v${PACKAGE_VERSION}-linux-amd64.tar.gz && \
|
||||
tar xf /app/etcd-v${PACKAGE_VERSION}-linux-amd64.tar.gz && \
|
||||
mv /app/etcd-v${PACKAGE_VERSION}-linux-amd64/* /app/
|
||||
|
||||
# Default command to build RPMs
|
||||
CMD nfpm pkg --config /app/nfpm.yaml --target /app/dist --packager rpm
|
||||
60
rpms/etcd/nfpm.yaml
Normal file
60
rpms/etcd/nfpm.yaml
Normal file
@ -0,0 +1,60 @@
|
||||
# nfpm.yaml
|
||||
|
||||
name: etcd
|
||||
version: ${PACKAGE_VERSION}
|
||||
release: ${PACKAGE_RELEASE}
|
||||
arch: amd64
|
||||
platform: linux
|
||||
section: default
|
||||
priority: extra
|
||||
description: "A distributed, reliable key-value store for the most critical data of a distributed system."
|
||||
|
||||
maintainer: https://etcd.io/
|
||||
homepage: https://etcd.io/
|
||||
license: Apache-2.0
|
||||
|
||||
disable_globbing: false
|
||||
|
||||
replaces:
|
||||
- etcd
|
||||
- etcdctl
|
||||
- etcdutl
|
||||
|
||||
provides:
|
||||
- etcd
|
||||
- etcdctl
|
||||
- etcdutl
|
||||
|
||||
# Files to include in the package
|
||||
contents:
|
||||
- src: /app/etcd
|
||||
dst: /usr/bin/etcd
|
||||
file_info:
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
- src: /app/etcdctl
|
||||
dst: /usr/bin/etcdctl
|
||||
file_info:
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
- src: /app/etcdutl
|
||||
dst: /usr/bin/etcdutl
|
||||
file_info:
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
- src: /app/resources/etcd.service
|
||||
dst: /usr/lib/systemd/system/etcd.service
|
||||
file_info:
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
# Scripts to run during installation/removal (optional)
|
||||
scripts:
|
||||
preinstall: ./resources/scripts/preinstall.sh
|
||||
postinstall: ./resources/scripts/postinstall.sh
|
||||
preremove: ./resources/scripts/preremove.sh
|
||||
postremove: ./resources/scripts/postremove.sh
|
||||
18
rpms/etcd/resources/etcd.service
Normal file
18
rpms/etcd/resources/etcd.service
Normal file
@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=etcd key-value store
|
||||
Documentation=https://github.com/etcd-io/etcd
|
||||
After=network-online.target local-fs.target remote-fs.target time-sync.target
|
||||
Wants=network-online.target local-fs.target remote-fs.target time-sync.target
|
||||
|
||||
[Service]
|
||||
User=etcd
|
||||
Type=notify
|
||||
Environment=ETCD_DATA_DIR=/var/lib/etcd
|
||||
Environment=ETCD_NAME=%m
|
||||
ExecStart=/usr/bin/etcd
|
||||
Restart=always
|
||||
RestartSec=10s
|
||||
LimitNOFILE=40000
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
2
rpms/etcd/resources/scripts/postinstall.sh
Executable file
2
rpms/etcd/resources/scripts/postinstall.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
systemctl daemon-reload
|
||||
3
rpms/etcd/resources/scripts/postremove.sh
Executable file
3
rpms/etcd/resources/scripts/postremove.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
rm -f /usr/lib/systemd/system/etcd.service
|
||||
systemctl daemon-reload
|
||||
5
rpms/etcd/resources/scripts/preinstall.sh
Executable file
5
rpms/etcd/resources/scripts/preinstall.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
groupadd --system etcd
|
||||
useradd --system --shell /sbin/nologin --no-create-home --home-dir /var/lib/etcd --gid etcd etcd
|
||||
mkdir -p /var/lib/etcd
|
||||
chown etcd:etcd /var/lib/etcd
|
||||
2
rpms/etcd/resources/scripts/preremove.sh
Executable file
2
rpms/etcd/resources/scripts/preremove.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
systemctl stop etcd.service
|
||||
Loading…
Reference in New Issue
Block a user