R
Railway•11mo ago
Rozukai

cURL issue at start

Hi, I got a script that call another service to init some var environement like this :
#!/usr/bin/env bash

if [ -z "$TOKEN_PROVIDER_ADDR" ]; then
echo "TOKEN_PROVIDER_ADDR environment variable is not set"
exit 1
fi

sleep 20

# API URL
PROVIDER_API_URL=$TOKEN_PROVIDER_ADDR/token/provide

echo "Fetching key from $PROVIDER_API_URL"

# Fetch the token
TOKEN=$(curl -s -v $PROVIDER_API_URL)

echo "Key: $TOKEN"

# Check if the key is retrieved successfully
if [ -z "$KEY" ]; then
echo "Failed to fetch key from API"
exit 1
fi

# Export the key as an environment variable
export TOKEN=$TOKEN

# Run your application
/app
#!/usr/bin/env bash

if [ -z "$TOKEN_PROVIDER_ADDR" ]; then
echo "TOKEN_PROVIDER_ADDR environment variable is not set"
exit 1
fi

sleep 20

# API URL
PROVIDER_API_URL=$TOKEN_PROVIDER_ADDR/token/provide

echo "Fetching key from $PROVIDER_API_URL"

# Fetch the token
TOKEN=$(curl -s -v $PROVIDER_API_URL)

echo "Key: $TOKEN"

# Check if the key is retrieved successfully
if [ -z "$KEY" ]; then
echo "Failed to fetch key from API"
exit 1
fi

# Export the key as an environment variable
export TOKEN=$TOKEN

# Run your application
/app
But I got this error :
Fetching key from http://xxx.railway.internal:8000/token/provide
* Host xxx.railway.internal:8000 was resolved.
* IPv6: fd12:e63e:8590::80:9c86:bbc9
* IPv4: (none)
* Trying [fd12:e63e:8590::80:9c86:bbc9]:8000...
* connect to fd12:e63e:8590::80:9c86:bbc9 port 8000 from fd12:e63e:8590::92:8458:6384 port 38030 failed: Connection refused
* Failed to connect to xxx.railway.internal port 8000 after 3 ms: Couldn't connect to server
* Closing connection
Key:
Failed to fetch key from API
Fetching key from http://xxx.railway.internal:8000/token/provide
* Host xxx.railway.internal:8000 was resolved.
* IPv6: fd12:e63e:8590::80:9c86:bbc9
* IPv4: (none)
* Trying [fd12:e63e:8590::80:9c86:bbc9]:8000...
* connect to fd12:e63e:8590::80:9c86:bbc9 port 8000 from fd12:e63e:8590::92:8458:6384 port 38030 failed: Connection refused
* Failed to connect to xxx.railway.internal port 8000 after 3 ms: Couldn't connect to server
* Closing connection
Key:
Failed to fetch key from API
I've just changed the host name by xxx for privacy purpose.
9 Replies
Percy
Percy•11mo ago
Project ID: 62a7d631-15d2-4bde-a633-b2e28b306105
Rozukai
RozukaiOP•11mo ago
62a7d631-15d2-4bde-a633-b2e28b306105 Here is my final "FROM" in my Dockerfile :
FROM bash:4.1.17 AS final

# Import the user and group files from the first stage.
COPY --from=builder /user/group /user/passwd /etc/

# Import the Certificate-Authority certificates for enabling HTTPS.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

# Import the compiled executable from the first stage.
COPY --from=builder /app /app

# Import the start script
COPY --from=builder /usr/local/go/src/github.com/EzeXchange-API/APICore/start.sh /start.sh
RUN chmod +x /start.sh

RUN apk add --no-cache curl

# Perform any further action as an unprivileged user.
USER nobody:nobody

EXPOSE 8000

# Run the compiled binary.
ENTRYPOINT ["bash", "/start.sh"]
FROM bash:4.1.17 AS final

# Import the user and group files from the first stage.
COPY --from=builder /user/group /user/passwd /etc/

# Import the Certificate-Authority certificates for enabling HTTPS.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

# Import the compiled executable from the first stage.
COPY --from=builder /app /app

# Import the start script
COPY --from=builder /usr/local/go/src/github.com/EzeXchange-API/APICore/start.sh /start.sh
RUN chmod +x /start.sh

RUN apk add --no-cache curl

# Perform any further action as an unprivileged user.
USER nobody:nobody

EXPOSE 8000

# Run the compiled binary.
ENTRYPOINT ["bash", "/start.sh"]
My Dockerfile build fine And I've activated the private networking of course
Brody
Brody•11mo ago
what kind of app are you trying to fetch the token from
Rozukai
RozukaiOP•11mo ago
It's a Golang fiber custom API
Rozukai
RozukaiOP•11mo ago
No description
Rozukai
RozukaiOP•11mo ago
This app work well
Solution
Brody
Brody•11mo ago
Rozukai
RozukaiOP•11mo ago
Thanks, I will try 😉 It worked, thanks a lot, you can close this
Brody
Brody•11mo ago
no problem!
Want results from more Discord servers?
Add your server