Skip to content

Commit d12d49c

Browse files
author
pho
committed
Fix Docker startup handling for release images
1 parent 5b47467 commit d12d49c

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- "v*"
7+
- "[0-9]*.[0-9]*.[0-9]*"
78
workflow_dispatch:
89

910
env:

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ COPY backend-bun/src /app/backend-bun/src
3232
COPY backend-bun/config /app/backend-bun/config
3333
RUN mkdir -p /app/backend-bun/logs /app/frontend-solid
3434

35+
COPY docker-entrypoint.sh /usr/local/bin/mediaflick-entrypoint
36+
RUN chmod +x /usr/local/bin/mediaflick-entrypoint
37+
3538
COPY frontend-solid/server.ts /app/frontend-solid/server.ts
3639
COPY --from=frontend-build /build/frontend-solid/dist /app/frontend-solid/dist
3740

3841
EXPOSE 3867 5000
3942

40-
CMD ["sh", "-c", "set -e; PORT=${BACKEND_PORT} bun /app/backend-bun/src/app/server.ts & backend_pid=$!; trap 'kill ${backend_pid} >/dev/null 2>&1 || true' INT TERM EXIT; PORT=${FRONTEND_PORT} BACKEND_HTTP_ORIGIN=http://127.0.0.1:${BACKEND_PORT} BACKEND_WS_ORIGIN=ws://127.0.0.1:${BACKEND_PORT} bun /app/frontend-solid/server.ts"]
43+
ENTRYPOINT ["/usr/local/bin/mediaflick-entrypoint"]

docker-entrypoint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
set -e
3+
4+
run_mediaflick() {
5+
PORT="${BACKEND_PORT}" bun /app/backend-bun/src/app/server.ts &
6+
backend_pid=$!
7+
trap 'kill "${backend_pid}" >/dev/null 2>&1 || true' INT TERM EXIT
8+
9+
PORT="${FRONTEND_PORT}" \
10+
BACKEND_HTTP_ORIGIN="http://127.0.0.1:${BACKEND_PORT}" \
11+
BACKEND_WS_ORIGIN="ws://127.0.0.1:${BACKEND_PORT}" \
12+
bun /app/frontend-solid/server.ts
13+
}
14+
15+
if [ "$#" -eq 0 ]; then
16+
run_mediaflick
17+
fi
18+
19+
if [ "$#" -eq 1 ] && [ "$1" = "start" ]; then
20+
run_mediaflick
21+
fi
22+
23+
if [ "$#" -eq 2 ] && [ "$1" = "bun" ] && [ "$2" = "start" ]; then
24+
run_mediaflick
25+
fi
26+
27+
if [ "$#" -eq 3 ] && [ "$1" = "bun" ] && [ "$2" = "run" ] && [ "$3" = "start" ]; then
28+
run_mediaflick
29+
fi
30+
31+
exec "$@"

0 commit comments

Comments
 (0)