2 years ago
Go Project is building but the deployment gives an error:
/bin/bash: line 1: ./out: No such file or directory
could a brave soul lend me a hand?
28 Replies
2 years ago
build logs please -
[Region: us-west1]
Using Nixpacks
context: d8d1dc40cb7d7ec83b41a303743833b0
╔════════════ Nixpacks v1.21.2 ════════════╗
║ setup │ go ║
║──────────────────────────────────────────║
║ install │ go mod download ║
║──────────────────────────────────────────║
║ build │ go build cmd/server/main.go ║
║──────────────────────────────────────────║
║ start │ ./out ║
╚══════════════════════════════════════════╝
0 building with "default" instance using docker driver
1 [internal] load build definition from Dockerfile
1 transferring dockerfile: 2.36kB done
1 DONE 0.1s
2 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1707782610
2 …
3 [internal] load metadata for docker.io/library/ubuntu:jammy
3 DONE 0.3s
2 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1707782610
2 DONE 0.5s
4 [stage-0 1/11] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1707782610@sha256:8f4b0fd95dc3311cf9a59f236d8d7d7f956fe21a2a1d64b53c82f12c4e859f09
4 DONE 0.0s
5 [stage-0 2/11] WORKDIR /app/
5 CACHED
6 [stage-1 1/5] FROM docker.io/library/ubuntu:jammy@sha256:a6d2b38300ce017add71440577d5b0a90460d0e57fd7aec21dd0d1b0761bbfb2
6 DONE 0.0s
7 [internal] load .dockerignore
7 transferring context: 2B done
7 DONE 0.1s
8 [internal] load build context
8 transferring context: 118.90kB 0.1s done
8 DONE 0.2s
2 years ago
have you changed your build command?
i tried setting my start command to go run cmd/server/main.go but it didnt fix the issue
2 years ago
try changing it to go build -o out cmd/server/main.go
the deployment is succesful, thank you very much
i'm trying to connect to the postgresdb do you know what env variables i should use? i'm currently using these ones:

2 years ago
you would use the variables that your code uses
2 years ago
what variables does your code use?
connectionString := "host=localhost port=5432 user=postgres password=pass dbname=gira sslmode=disable"
i've set it up like this, but i'm not sure what variable to use for dbname:

2 years ago
PGDATABASE
2 years ago
you can hover your mouse to the right of the hidden text to show you an eye icon that will temporarily show you the value
do these values change per instance? or are they consistent across db deployments?
2 years ago
the database name would be the same across all deployments of postgres, but you should still use an environment variable for it
