Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b20c63c

Browse files
recanmankylecarbs
andauthored
fix: install openrc service on alpine (#12294) (#12870)
* fix: install openrc service on alpine (#12294) * fmt --------- Co-authored-by: Kyle Carberry <[email protected]>
1 parent 060f023 commit b20c63c

File tree

4 files changed

+114
-1
lines changed

4 files changed

+114
-1
lines changed

scripts/linux-pkg/coder-openrc

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/sbin/openrc-run
2+
name=coder
3+
description="Coder - Self-hosted developer workspaces on your infra"
4+
document="https://coder.com/docs/coder-oss"
5+
6+
depend() {
7+
need net
8+
after net-online
9+
use dns logger
10+
}
11+
12+
checkpath --directory --owner coder:coder --mode 0700 /var/cache/coder
13+
14+
start_pre() {
15+
if [ ! -f /etc/coder.d/coder.env ]; then
16+
eerror "/etc/coder.d/coder.env file does not exist"
17+
return 1
18+
fi
19+
# Read and export environment variables ignoring comment lines and blank lines
20+
while IFS= read -r line; do
21+
# Skip blank or comment lines
22+
if [ -z "$line" ] || [[ "$line" =~ ^# ]]; then
23+
continue
24+
fi
25+
export "$line"
26+
done < /etc/coder.d/coder.env
27+
}
28+
29+
command="/usr/bin/coder"
30+
command_args="server"
31+
command_user="coder:coder"
32+
command_background="yes"
33+
pidfile="/run/coder.pid"
34+
35+
restart="always"
36+
restart_delay="5"
37+
38+
stop_timeout="90"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/sbin/openrc-run
2+
name=coder-workspace-proxy
3+
description="Coder - external workspace proxy server"
4+
document="https://coder.com/docs/coder-oss"
5+
6+
depend() {
7+
need net
8+
after net-online
9+
use dns logger
10+
}
11+
12+
checkpath --directory --owner coder:coder --mode 0700 /var/cache/coder
13+
14+
start_pre() {
15+
if [ ! -f /etc/coder.d/coder-workspace-proxy.env ]; then
16+
eerror "/etc/coder.d/coder-workspace-proxy.env file does not exist"
17+
return 1
18+
fi
19+
20+
# Read and export environment variables ignoring comment lines and blank lines
21+
while IFS= read -r line; do
22+
# Skip blank or comment lines
23+
if [ -z "$line" ] || [[ "$line" =~ ^# ]]; then
24+
continue
25+
fi
26+
export "$line"
27+
done < /etc/coder.d/coder-workspace-proxy.env
28+
}
29+
30+
command="/usr/bin/coder"
31+
command_args="workspace-proxy server"
32+
command_user="coder:coder"
33+
command_background="yes"
34+
pidfile="/run/coder-workspace-proxy.pid"
35+
36+
restart="always"
37+
restart_delay="5"
38+
39+
stop_timeout="90"

scripts/linux-pkg/nfpm-alpine.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: coder
2+
platform: linux
3+
arch: "${GOARCH}"
4+
version: "${CODER_VERSION}"
5+
version_schema: semver
6+
release: 1
7+
8+
vendor: Coder
9+
homepage: https://coder.com
10+
maintainer: Coder <[email protected]>
11+
description: |
12+
Provision development environments with infrastructure with code
13+
license: AGPL-3.0
14+
suggests:
15+
- postgresql
16+
17+
scripts:
18+
preinstall: preinstall.sh
19+
20+
contents:
21+
- src: coder
22+
dst: /usr/bin/coder
23+
- src: coder.env
24+
dst: /etc/coder.d/coder.env
25+
type: "config|noreplace"
26+
- src: coder-workspace-proxy-openrc
27+
dst: /etc/init.d/coder-workspace-proxy
28+
- src: coder-openrc
29+
dst: /etc/init.d/coder

scripts/package.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,16 @@ ln "$(realpath scripts/linux-pkg/coder.service)" "$temp_dir/"
8989
ln "$(realpath scripts/linux-pkg/nfpm.yaml)" "$temp_dir/"
9090
ln "$(realpath scripts/linux-pkg/preinstall.sh)" "$temp_dir/"
9191

92+
nfpm_config_file="nfpm.yaml"
93+
94+
# Use nfpm-alpine.yaml when building for Alpine (OpenRC).
95+
if [[ "$format" == "apk" ]]; then
96+
nfpm_config_file="nfpm-alpine.yaml"
97+
fi
98+
9299
pushd "$temp_dir"
93100
GOARCH="$arch" CODER_VERSION="$version" nfpm package \
94-
-f nfpm.yaml \
101+
-f "$nfpm_config_file" \
95102
-p "$format" \
96103
-t "$output_path" \
97104
1>&2

0 commit comments

Comments
 (0)