Skip to content

Commit 4855dee

Browse files
committed
Update codeoss-server image
1 parent e09c200 commit 4855dee

File tree

7 files changed

+81
-1
lines changed

7 files changed

+81
-1
lines changed

.DS_Store

10 KB
Binary file not shown.

codeoss-server/certbot_renew.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
# https://certbot.eff.org/instructions?ws=nginx&os=debianbuster
3+
4+
certbot renew --quiet --renew-hook "systemctl restart nginx.service"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
mail="$1"
4+
domain="$2"
5+
6+
{
7+
certbot certonly --manual -m "$mail" -d "$domain" --preferred-challenges dns
8+
} || {
9+
echo "certbot generated with error!"
10+
}
11+
12+
CODEOSS_SERVER_CONTAINER_ID=$(podman run -itd \
13+
-p 8000:8000 -h "codeoss-server" \
14+
ghcr.io/lcjuves/codeoss-server)
15+
echo "CodeOSS server's container id: $CODEOSS_SERVER_CONTAINER_ID"
16+
17+
mv /etc/nginx/conf.d/localhost.conf /etc/nginx/conf.d/"$domain".conf
18+
sed -i "s/localhost/$domain/g" /etc/nginx/conf.d/"$domain".conf
19+
20+
systemctl start nginx.service

codeoss-server/localhost.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
server {
2+
listen 443 ssl;
3+
server_name localhost;
4+
5+
location / {
6+
proxy_redirect off;
7+
proxy_pass http://127.0.0.1:8000;
8+
# https://github.com/nginx/nginx/blob/release-1.28.0/src/http/modules/ngx_http_proxy_module.c#L293
9+
proxy_http_version 1.1;
10+
proxy_set_header Host $http_host;
11+
proxy_set_header X-Real-IP $remote_addr;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
}
14+
15+
ssl on;
16+
ssl_certificate /etc/letsencrypt/live/localhost/fullchain.pem;
17+
ssl_certificate_key /etc/letsencrypt/live/localhost/privkey.pem;
18+
ssl_session_timeout 3m;
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
if [ -z "$domain" ]; then
4+
domain=localhost
5+
fi
6+
7+
if [ -z "$mail" ]; then
8+
mail=mail@localhost
9+
fi
10+
11+
if [ -z "$sec_key" ]; then
12+
sec_key="$(date +%s)"
13+
fi
14+
15+
mount -t cgroup
16+
17+
CODEOSS_SERVER_SELF_HOSTED_CONTAINER_ID=$(podman run -itd --privileged \
18+
-h "$(echo "$domain" | base64)" \
19+
-v /var/run/podman/podman.sock:/var/run/podman/podman.sock \
20+
-p 443:443 \
21+
ghcr.io/lcjuves/codeoss-server:self-hosted /sbin/init)
22+
23+
podman exec -it \
24+
--workdir /root "$CODEOSS_SERVER_SELF_HOSTED_CONTAINER_ID" \
25+
bash -e init-self-hosted-codeoss-server.sh "$mail" "$domain"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM container-base
2+
RUN apt-get install -y curl podman
3+
4+
RUN apt-get install -y nginx net-tools
5+
EXPOSE 443
6+
7+
RUN apt-get install -y certbot vim
8+
WORKDIR /root
9+
ADD certbot_renew.sh .
10+
ADD localhost.conf /etc/nginx/conf.d/
11+
12+
ADD init-self-hosted-codeoss-server.sh .

containerImages2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
{
77
"name": "codeoss-server",
8-
"tags": ["latest"]
8+
"tags": ["self-hosted", "latest"]
99
},
1010
{
1111
"name": "container-image-builder",

0 commit comments

Comments
 (0)