Add Dockerfile and Makefile for cloudflared tunnel setup; include startup script
This commit is contained in:
@@ -40,15 +40,9 @@ COPY config.json /etc/cloudflared/config.json
|
||||
# Copy the binary from builder
|
||||
COPY --from=builder /app/monaco-backend /monaco-backend
|
||||
|
||||
# Add startup script
|
||||
RUN echo '#!/bin/sh\n\
|
||||
# Start the backend\n\
|
||||
/monaco-backend & \n\
|
||||
# Wait for backend to start\n\
|
||||
sleep 5\n\
|
||||
# Start cloudflared tunnel using config file\n\
|
||||
cloudflared tunnel --no-autoupdate run --config /etc/cloudflared/config.json\n\
|
||||
' > /start.sh && chmod +x /start.sh
|
||||
# Copy the startup script
|
||||
COPY start.sh /start.sh
|
||||
RUN chmod +x /start.sh
|
||||
|
||||
# Expose port for local access
|
||||
EXPOSE 8080
|
||||
|
||||
21
new-backend/Makefile
Normal file
21
new-backend/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
.PHONY: build run run-detached stop logs
|
||||
|
||||
# Build the image
|
||||
build:
|
||||
docker-compose -f docker-compose.tunnel.yml build
|
||||
|
||||
# Run the container
|
||||
run: build
|
||||
docker-compose -f docker-compose.tunnel.yml up
|
||||
|
||||
# Run in detached mode
|
||||
run-detached: build
|
||||
docker-compose -f docker-compose.tunnel.yml up -d
|
||||
|
||||
# Stop the container
|
||||
stop:
|
||||
docker-compose -f docker-compose.tunnel.yml down
|
||||
|
||||
# View logs
|
||||
logs:
|
||||
docker-compose -f docker-compose.tunnel.yml logs -f
|
||||
16
new-backend/start.sh
Normal file
16
new-backend/start.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Start the backend
|
||||
/monaco-backend &
|
||||
BACKEND_PID=$!
|
||||
echo "Backend started with PID: $BACKEND_PID"
|
||||
|
||||
# Wait for backend to start
|
||||
echo "Waiting for backend to initialize..."
|
||||
sleep 5
|
||||
|
||||
# Start cloudflared tunnel using config file
|
||||
echo "Starting Cloudflare tunnel to api.ishikabhoyar.tech..."
|
||||
cloudflared tunnel --no-autoupdate run --config /etc/cloudflared/config.json
|
||||
|
||||
# If cloudflared exits, kill the backend too
|
||||
kill $BACKEND_PID
|
||||
Reference in New Issue
Block a user