Skip to content

Commit f7c306e

Browse files
authored
Merge branch 'develop' into feat/add-zig-wasm
2 parents dbfc085 + 4082e05 commit f7c306e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2897
-145
lines changed

.dockerignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
node_modules
22
*/node_modules
3+
*/build
34
docs/.docusaurus
4-
package-lock.json
5-
build
65
.vscode
76
.jest
87
build
@@ -18,4 +17,4 @@ docs/static/llms-full.txt
1817
/playwright-report/
1918
/playwright/.cache/
2019
src/livecodes/i18n/locales/tmp/
21-
lokalise_tmp
20+
lokalise_tmp

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Docker Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: SSH to server
13+
uses: appleboy/ssh-action@v1
14+
with:
15+
host: ${{ secrets.VPS_HOST }}
16+
username: ${{ secrets.VPS_USER }}
17+
key: ${{ secrets.VPS_KEY }}
18+
passphrase: ${{ secrets.VPS_PASSPHRASE }}
19+
script: |
20+
set -e
21+
cd livecodes
22+
git checkout main
23+
git pull origin main
24+
echo "${{ vars.VPS_ENV }}" > .env
25+
docker compose build
26+
docker compose up -d
27+
docker container prune -f
28+
docker image prune -a -f

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ jobs:
8282
CF_ZONE: ${{ secrets.CF_ZONE }}
8383
CF_TOKEN: ${{ secrets.CF_TOKEN }}
8484

85+
# - name: Build and Push to Docker Hub
86+
# run: |
87+
# echo ${{secrets.DOCKERHUB_TOKEN}} | docker login --username ${{ vars.DOCKERHUB_USERNAME }} --password-stdin
88+
# docker build -t ${{ vars.DOCKERHUB_USERNAME }}/livecodes:latest -t ${{ vars.DOCKERHUB_USERNAME }}/livecodes:${{steps.vars.outputs.version}} .
89+
# docker push ${{ vars.DOCKERHUB_USERNAME }}/livecodes:latest
90+
# docker push ${{ vars.DOCKERHUB_USERNAME }}/livecodes:${{steps.vars.outputs.version}}
91+
8592
- name: Publish SDK to NPM
8693
if: startsWith(github.head_ref, 'releases/sdk-v')
8794
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ dist
44
.cache
55
**/*.log
66
.env
7+
/ignore
8+
*.ignore.*
79
docs/docs/api
810
docs/static/**/*.html.md
911
docs/static/llms.txt
@@ -13,3 +15,4 @@ docs/static/llms-full.txt
1315
/playwright/.cache/
1416
src/livecodes/i18n/locales/tmp/
1517
lokalise_tmp
18+
/server/data

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"Build",
2525
"services",
2626
"CommandMenu",
27-
"Accessibility"
27+
"Accessibility",
28+
"self-hosting"
2829
],
2930
"html.customData": ["./.vscode/html.html-data.json"]
3031
}

Dockerfile

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
FROM node:24.1.0-alpine3.21 AS build-stage
2-
RUN apk update && apk add git
1+
FROM node:24.1.0-alpine3.21 AS builder
2+
3+
RUN apk update --no-cache && apk add --no-cache git
34

4-
# set the working directory
55
WORKDIR /app
6-
# Copy the working directory in the container
6+
7+
COPY package*.json ./
8+
COPY docs/package*.json docs/
9+
COPY storybook/package*.json storybook/
10+
COPY server/package*.json server/
11+
12+
RUN npm ci
13+
714
COPY . .
8-
# Install the project dependencies
9-
RUN npm install
10-
# Build the application to the production mode to dist folder
11-
RUN npm run build
1215

16+
ARG SELF_HOSTED
17+
ARG SELF_HOSTED_SHARE
18+
ARG SELF_HOSTED_BROADCAST
19+
ARG BROADCAST_PORT
20+
ARG SANDBOX_HOST_NAME
21+
ARG SANDBOX_PORT
22+
ARG FIREBASE_CONFIG
23+
ARG DOCS_BASE_URL
24+
25+
RUN if [ "$DOCS_BASE_URL" == "null" ]; \
26+
then npm run build:app; \
27+
else npm run build; \
28+
fi
29+
30+
FROM node:24.1.0-alpine3.21 AS server
31+
32+
RUN addgroup -S appgroup
33+
RUN adduser -S appuser -G appgroup
34+
35+
RUN mkdir -p /srv && chown -R appuser:appgroup /srv
36+
37+
USER appuser
38+
39+
WORKDIR /srv
40+
41+
COPY server/package*.json ./
42+
43+
RUN npm ci
44+
45+
COPY --from=builder /app/build/ build/
46+
47+
COPY functions/ functions/
48+
COPY server/src/ server/src/
49+
COPY src/livecodes/html/sandbox/ server/src/sandbox/
1350

14-
# Use a lightweight web server to serve the built application
15-
FROM httpd:2.4 AS production-stage
16-
# Copy the build application from the previous stage to the Nginx container
17-
COPY --from=build-stage /app/build /usr/local/apache2/htdocs/
18-
CMD ["httpd-foreground"]
51+
CMD ["node", "server/src/app.ts"]

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ LiveCodes uses services that are generously provided by:
275275
</img></a><br /><br />
276276
</p>
277277
<p>
278+
<a href="https://m.do.co/c/fb8c00b45b91" target="_blank" title="DigitalOcean">
279+
<img alt="DigitalOcean" width="200" src="https://dev.livecodes.io/docs/img/credits/digital-ocean.svg">
280+
</img></a><br /><br />
281+
</p>
282+
<p>
278283
<a href="https://bundlejs.com/" target="_blank" title="bundlejs">
279284
<img alt="bundlejs" width="200" src="https://dev.livecodes.io/docs/img/credits/bundlejs.jpg">
280285
</img></a><br /><br />

docker-compose.yml

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,72 @@
11
services:
2-
live-codes:
2+
app:
33
build:
44
context: .
55
dockerfile: Dockerfile
6-
image: result/latest
6+
args:
7+
- SELF_HOSTED=true
8+
- SELF_HOSTED_SHARE=${SELF_HOSTED_SHARE:-true}
9+
- SELF_HOSTED_BROADCAST=${SELF_HOSTED_BROADCAST:-true}
10+
- BROADCAST_PORT=${BROADCAST_PORT:-3030}
11+
- SANDBOX_HOST_NAME=${SANDBOX_HOST_NAME:-${HOST_NAME:-livecodes.localhost}}
12+
- SANDBOX_PORT=${SANDBOX_PORT:-8090}
13+
- FIREBASE_CONFIG=${FIREBASE_CONFIG:-}
14+
- DOCS_BASE_URL=${DOCS_BASE_URL:-null}
15+
restart: unless-stopped
16+
environment:
17+
- SELF_HOSTED=true
18+
- HOST_NAME=${HOST_NAME:-livecodes.localhost}
19+
- PORT=${PORT:-443}
20+
- SELF_HOSTED_SHARE=${SELF_HOSTED_SHARE:-true}
21+
- SELF_HOSTED_BROADCAST=${SELF_HOSTED_BROADCAST:-true}
22+
- BROADCAST_PORT=${BROADCAST_PORT:-3030}
23+
- BROADCAST_TOKENS=${BROADCAST_TOKENS:-}
24+
- SANDBOX_HOST_NAME=${SANDBOX_HOST_NAME:-${HOST_NAME:-livecodes.localhost}}
25+
- SANDBOX_PORT=${SANDBOX_PORT:-8090}
26+
- LOG_URL=${LOG_URL:-null}
27+
- VALKEY_HOST=valkey
28+
- VALKEY_PORT=6379
29+
volumes:
30+
- ./assets:/srv/build/assets
31+
depends_on:
32+
- valkey
33+
34+
valkey:
35+
image: valkey/valkey:8.1.2-alpine3.22
36+
restart: on-failure
37+
volumes:
38+
- valkey-data:/data
39+
command:
40+
[
41+
'sh',
42+
'-c',
43+
'if [ "$SELF_HOSTED_SHARE" != "false" ]; then valkey-server --save 60 1 --loglevel warning; fi',
44+
]
45+
46+
server:
47+
image: caddy:2.10.0-alpine
48+
entrypoint: ['/bin/sh', './entrypoint.sh']
49+
command: ['caddy', 'run', '--config', '/etc/caddy/Caddyfile', '--adapter', 'caddyfile']
750
restart: unless-stopped
851
ports:
9-
- 8080:80
52+
- '80:80'
53+
- '${PORT:-443}:${PORT:-443}'
54+
- '${SANDBOX_PORT:-8090}:${SANDBOX_PORT:-8090}'
55+
- '${BROADCAST_PORT:-3030}:${BROADCAST_PORT:-3030}'
56+
environment:
57+
- HOST_NAME=${HOST_NAME:-livecodes.localhost}
58+
- PORT=${PORT:-443}
59+
- SANDBOX_HOST_NAME=${SANDBOX_HOST_NAME:-${HOST_NAME:-livecodes.localhost}}
60+
- SANDBOX_PORT=${SANDBOX_PORT:-8090}
61+
- BROADCAST_PORT=${BROADCAST_PORT:-3030}
62+
volumes:
63+
- ./server/caddy/entrypoint.sh:/srv/entrypoint.sh
64+
- ./server/caddy/Caddyfile:/etc/caddy/Caddyfile
65+
- ./server/data/caddy/data:/data
66+
- ./server/data/caddy/config:/config
67+
depends_on:
68+
- app
69+
70+
volumes:
71+
valkey-data:
72+
name: livecodes-share-data

0 commit comments

Comments
 (0)