Hello guys!
I am building an fly.io app where I have to use tailscale to assign a ip address to my machine.
I have followed the guide from tailscale (guide here) but my app instance dies after deploying.
It goes like this:
- I deploy my app with fly.io command
- The docker image gets built
- Fly creates a release
- App instance dies after 2 restarts
Logs:
2023-04-09T12:35:25Z runner[5a160520] ams [info]Starting instance
2023-04-09T12:35:25Z runner[5a160520] ams [info]Configuring virtual machine
2023-04-09T12:35:25Z runner[5a160520] ams [info]Pulling container image
2023-04-09T12:35:29Z runner[5a160520] ams [info]Unpacking image
2023-04-09T12:35:31Z runner[5a160520] ams [info]Preparing kernel init
2023-04-09T12:35:31Z runner[5a160520] ams [info]Configuring firecracker
2023-04-09T12:35:31Z runner[5a160520] ams [info]Starting virtual machine
2023-04-09T12:35:31Z app[5a160520] ams [info]Starting init (commit: 9e69c24)...
2023-04-09T12:35:31Z app[5a160520] ams [info]Preparing to run: `/bin/sh` as root
2023-04-09T12:35:31Z app[5a160520] ams [info]2023/04/09 12:35:31 listening on [fdaa:0:9e39:a7b:10e:5a16:520:2]:22 (DNS: [fdaa::3]:53)
2023-04-09T12:35:32Z app[5a160520] ams [info]Starting clean up.
2023-04-09T12:35:33Z health[5a160520] ams [warn]Health check on port 8081 is in a 'warning' state. Your app may not be responding properly. Services exposed on ports [80, 443] may have intermittent failures until the health check passes.
2023-04-09T12:35:37Z runner[5a160520] ams [info]Starting instance
2023-04-09T12:35:38Z runner[5a160520] ams [info]Configuring virtual machine
2023-04-09T12:35:38Z runner[5a160520] ams [info]Pulling container image
2023-04-09T12:35:38Z runner[5a160520] ams [info]Unpacking image
2023-04-09T12:35:38Z runner[5a160520] ams [info]Preparing kernel init
2023-04-09T12:35:39Z runner[5a160520] ams [info]Configuring firecracker
2023-04-09T12:35:39Z runner[5a160520] ams [info]Starting virtual machine
2023-04-09T12:35:39Z app[5a160520] ams [info]Starting init (commit: 9e69c24)...
2023-04-09T12:35:39Z app[5a160520] ams [info]Preparing to run: `/bin/sh` as root
2023-04-09T12:35:39Z app[5a160520] ams [info]2023/04/09 12:35:39 listening on [fdaa:0:9e39:a7b:10e:5a16:520:2]:22 (DNS: [fdaa::3]:53)
2023-04-09T12:35:40Z app[5a160520] ams [info]Starting clean up.
2023-04-09T12:35:45Z runner[5a160520] ams [info]Starting instance
2023-04-09T12:35:45Z runner[5a160520] ams [info]Configuring virtual machine
2023-04-09T12:35:45Z runner[5a160520] ams [info]Pulling container image
2023-04-09T12:35:46Z runner[5a160520] ams [info]Unpacking image
2023-04-09T12:35:46Z runner[5a160520] ams [info]Preparing kernel init
2023-04-09T12:35:46Z runner[5a160520] ams [info]Configuring firecracker
2023-04-09T12:35:46Z runner[5a160520] ams [info]Starting virtual machine
2023-04-09T12:35:46Z app[5a160520] ams [info]Starting init (commit: 9e69c24)...
2023-04-09T12:35:46Z app[5a160520] ams [info]Preparing to run: `/bin/sh` as root
2023-04-09T12:35:46Z app[5a160520] ams [info]2023/04/09 12:35:46 listening on [fdaa:0:9e39:a7b:10e:5a16:520:2]:22 (DNS: [fdaa::3]:53)
2023-04-09T12:35:47Z app[5a160520] ams [info]Starting clean up.
2023-04-09T12:35:48Z health[5a160520] ams [warn]Health check on port 8081 is in a 'warning' state. Your app may not be responding properly. Services exposed on ports [80, 443] may have intermittent failures until the health check passes.
start.sh file (bash script):
#!/bin/sh
/app/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/var/run/tailscale/tailscaled.sock &
until /app/tailscale up --authkey=${TAILSCALE_AUTHKEY} --hostname=fly-app
do
echo "Currently connecting to tailnet"
sleep 0.1
done
echo "tailscale started"
(PS: Neither the echo messages get printed as you can see from the logs)
Dockerfile (PS: I am running Shopify App)
FROM node:18-alpine
ARG SHOPIFY_API_KEY
ENV SHOPIFY_API_KEY=$SHOPIFY_API_KEY
EXPOSE 8081
WORKDIR /app
COPY web .
RUN npm install
RUN cd frontend && npm install && npm run build
USER root
CMD ["npm", "run", "serve", "/app/start.sh"]
#tailscale
FROM alpine:latest as tailscale
WORKDIR /app
ENV TSFILE=tailscale_1.38.4_amd64.tgz
RUN wget https://pkgs.tailscale.com/stable/${TSFILE} && \
tar xzf ${TSFILE} --strip-components=1
COPY . ./
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:latest
RUN apk update && apk add ca-certificates iptables ip6tables && rm -rf /var/cache/apk/*
# Copy binary to production image
COPY --from=tailscale /app/start.sh /app/start.sh
COPY --from=tailscale /app/tailscaled /app/tailscaled
COPY --from=tailscale /app/tailscale /app/tailscale
RUN mkdir -p /var/run/tailscale
RUN mkdir -p /var/cache/tailscale
RUN mkdir -p /var/lib/tailscale
(PS: Dockerfile gets built successfully)
I am not really sure why my app dies after deployment.
Thanks!