Skip to content

Commit

Permalink
Actions test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanThrane committed Jan 31, 2025
1 parent 04a37fa commit 729d531
Show file tree
Hide file tree
Showing 17 changed files with 402 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "UCloud release"
on:
push:
tags:
- "test*"

jobs:
build-im2-rhel8:
runs-on: ubuntu-latest
container: almalinux:8
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: Get tag version (without 'v')
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/test}" >> $GITHUB_ENV

- name: Display tag name
run: |
echo "Tag pushed: ${{ env.TAG_NAME }}"
echo "${{ env.TAG_NAME }}" > backend/version.txt
- name: "Install dependencies (DNF)"
run: "dnf install -y git make wget rpm-build rpmdevtools gcc"

- name: "Install Go 1.23.5"
run: |
cd /tmp;
wget 'https://go.dev/dl/go1.23.5.linux-amd64.tar.gz';
tar xvf go*;
ln -s `realpath go/bin/go` /usr/bin/go;
ln -s `realpath go/bin/gofmt` /usr/bin/gofmt;
cd $GITHUB_WORKSPACE;
- name: "Build ucloud-psql"
run: |
cd ./provider-integration/rpmbuild
make ucloud-psql
cd $GITHUB_WORKSPACE
- name: "Build ucloud-envoy"
run: |
cd ./provider-integration/rpmbuild
make ucloud-envoy
cd $GITHUB_WORKSPACE
- name: "Build ucloud-envoy"
run: |
cd ./provider-integration/rpmbuild
make ucloud-envoy
cd $GITHUB_WORKSPACE
9 changes: 9 additions & 0 deletions provider-integration/rpmbuild/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TARGETS := $(subst /,,$(wildcard */))

.PHONY: $(TARGETS)

$(TARGETS):
cd $@; \
mkdir -p SOURCES; \
spectool -g SPECS/$@.spec -C SOURCES; \
rpmbuild --define "_topdir $(shell pwd)/$@" -ba SPECS/$@.spec
13 changes: 13 additions & 0 deletions provider-integration/rpmbuild/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# RPM Repository
This folder contains instructions for building custom RPM packages.
Start by installing the RPM build dependencies.

```bash
yum install -y rpm-build rpmdevtools
```

To build an RPM, such as `prometheus`, use the `make` command:

```bash
make prometheus
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UCLOUD_ENVOY_OPTS="--config-path /etc/ucloud/envoy/config.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable ucloud-envoy.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Envoy service proxy
Documentation=https://www.envoyproxy.io/docs
Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=-/etc/default/ucloud-envoy
ExecStartPre=+/bin/install -d -m 755 -o ucloud -g ucloud /var/run/ucloud/envoy
ExecStart=/opt/ucloud/envoy/envoy $UCLOUD_ENVOY_OPTS
User=ucloud
Group=ucloud
Type=simple

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dynamic_resources:
cds_config:
resource_api_version: V3
initial_fetch_timeout: 0.005s
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc:
cluster_name: xds_cluster
set_node_on_first_message_only: true
lds_config:
resource_api_version: V3
initial_fetch_timeout: 0.005s
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc:
cluster_name: xds_cluster
set_node_on_first_message_only: true
node:
id: ucloudim_stack
cluster: ucloudim_cluster
static_resources:
clusters:
- connect_timeout: 1s
load_assignment:
cluster_name: xds_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
pipe:
path: /var/run/ucloud/envoy/xds.sock
mode: 448
http2_protocol_options: {}
name: xds_cluster
layered_runtime:
layers:
- name: runtime-0
rtds_layer:
rtds_config:
resource_api_version: V3
initial_fetch_timeout: 0.005s
api_config_source:
transport_api_version: V3
api_type: GRPC
grpc_services:
envoy_grpc:
cluster_name: xds_cluster
name: runtime-0
68 changes: 68 additions & 0 deletions provider-integration/rpmbuild/ucloud-envoy/SPECS/ucloud-envoy.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Name: ucloud-envoy
Version: 1.23.12
Release: 1%{?dist}
Summary: Cloud-native high-performance service proxy
License: Apache-2.0
URL: https://www.envoyproxy.io

Requires(pre): shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
AutoReq: no

Source0: https://github.com/envoyproxy/envoy/releases/download/v%{version}/envoy-%{version}-linux-x86_64
Source1: https://raw.githubusercontent.com/envoyproxy/envoy/refs/heads/main/LICENSE
Source2: %{name}.service
Source3: %{name}.default
Source4: %{name}.preset
Source5: %{name}.yaml

%define debug_package %{nil}
%define appdir /opt/ucloud/envoy
%define etcdir /etc/ucloud/envoy

%description
Envoy is an open source edge and service proxy, designed for cloud-native applications

%prep

%build

%install
install -d -m 755 %{buildroot}%{appdir}
install -d -m 750 %{buildroot}%{etcdir}
install -D -m 755 %{SOURCE0} %{buildroot}%{appdir}/envoy
install -D -m 644 %{SOURCE1} %{buildroot}%{appdir}/LICENSE
install -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/default/%{name}
install -D -m 644 %{SOURCE4} %{buildroot}%{_presetdir}/50-%{name}.preset
install -D -m 644 %{SOURCE5} %{buildroot}%{etcdir}/config.yaml

%clean
rm -rf %{buildroot}
rm -rf %{_builddir}

%files
%defattr(-,root,root,-)
%{_unitdir}/%{name}.service
%{_presetdir}/50-%{name}.preset
%config(noreplace) %{_sysconfdir}/default/%{name}
/opt/ucloud
%attr(-,ucloud,ucloud) /etc/ucloud

%pre
getent group ucloud > /dev/null || groupadd -r ucloud
getent passwd ucloud > /dev/null || \
useradd -r -d /etc/ucloud -g ucloud \
-s /sbin/nologin -c "UCloud service account" ucloud
exit 0

%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service
2 changes: 2 additions & 0 deletions provider-integration/rpmbuild/ucloud-im/SOURCES/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ucloud ALL=(%ucloud_users) NOPASSWD:SETENV: /opt/ucloud/ucloud
ucloud ALL=(root) NOPASSWD: /sbin/sss_cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UCLOUD_IM_OPTS=""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable ucloud-im.service
18 changes: 18 additions & 0 deletions provider-integration/rpmbuild/ucloud-im/SOURCES/ucloud-im.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=UCloud Integration Module
Documentation=https://docs.cloud.sdu.dk/dev/index.html
Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=-/etc/default/ucloud-im
ExecStartPre=+/bin/install -d -m 755 -o ucloud -g ucloud /var/run/ucloud
ExecStartPre=+/bin/install -d -m 777 -o ucloud -g ucloud /var/log/ucloud
ExecStart=/opt/ucloud/ucloud $UCLOUD_IM_OPTS
ExecStopPost=+/bin/killall ucloud
User=ucloud
Group=ucloud
Type=simple

[Install]
WantedBy=multi-user.target
74 changes: 74 additions & 0 deletions provider-integration/rpmbuild/ucloud-im/SPECS/ucloud-im.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
%define version %(cat ../../backend/version.txt)

Name: ucloud-im
Version: %{version}
Release: 1%{?dist}
Summary: UCloud Integration Module
License: EUPL-1.2
URL: https://github.com/SDU-eScience/UCloud

BuildRequires: golang git
Requires(pre): shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

Source0: https://raw.githubusercontent.com/SDU-eScience/UCloud/refs/heads/master/LICENSE.md
Source1: sudoers
Source2: %{name}.service
Source3: %{name}.default
Source4: %{name}.preset

%define debug_package %{nil}
%define appdir /opt/ucloud
%define etcdir /etc/ucloud

%description
UCloud/IM is the middleware needed to integrated with the UCloud platform

%prep

%build
git clone --depth 1 https://github.com/SDU-eScience/UCloud
cd UCloud/provider-integration/im2
./build.sh

%install
install -d -m 755 %{buildroot}%{appdir}
install -d -m 755 %{buildroot}%{etcdir}
install -d -m 750 %{buildroot}%{_sysconfdir}/sudoers.d
install -D -m 755 %{_builddir}/UCloud/provider-integration/im2/bin/im %{buildroot}%{appdir}/ucloud
install -D -m 640 %{SOURCE1} %{buildroot}%{_sysconfdir}/sudoers.d/ucloud
install -D -m 644 %{SOURCE0} %{buildroot}%{appdir}/LICENSE
install -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/default/%{name}
install -D -m 644 %{SOURCE4} %{buildroot}%{_presetdir}/50-%{name}.preset

%clean
rm -rf %{buildroot}
rm -rf %{_builddir}

%files
%defattr(-,root,root,-)
%{_unitdir}/%{name}.service
%{_presetdir}/50-%{name}.preset
%config(noreplace) %{_sysconfdir}/default/%{name}
%config(noreplace) %{_sysconfdir}/sudoers.d/ucloud
/opt/ucloud
%attr(-,ucloud,ucloud) /etc/ucloud

%pre
getent group ucloud > /dev/null || groupadd -r ucloud
getent passwd ucloud > /dev/null || \
useradd -r -d /etc/ucloud -g ucloud \
-s /sbin/nologin -c "UCloud service account" ucloud
exit 0

%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UCLOUD_PSQL_OPTS="-D /etc/ucloud/psql/data -p 5432"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable ucloud-psql.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Embedded PostgreSQL
Documentation=https://github.com/zonkyio/embedded-postgres-binaries
Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=-/etc/default/ucloud-psql
ExecStart=/opt/ucloud/psql/bin/postgres $UCLOUD_PSQL_OPTS
User=ucloud
Group=ucloud
Type=simple

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 729d531

Please sign in to comment.