Can't build go project

Using a Dockerfile I can't seem to get the GOROOT working, and package imports seem to break.
# syntax=docker/dockerfile:1

FROM golang:1.21

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY * ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /server
CMD ["/server"]
# syntax=docker/dockerfile:1

FROM golang:1.21

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY * ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /server
CMD ["/server"]
#12 [6/6] RUN CGO_ENABLED=0 GOOS=linux go build -o /server



#12 1.402 authorization.go:6:2: package exotic/exotic-auth/db/chat_users_db/model is not in std (/usr/local/go/src/exotic/exotic-auth/db/chat_users_db/model)

#12 1.402 main.go:5:2: package exotic/exotic-auth/handlers is not in std (/usr/local/go/src/exotic/exotic-auth/handlers)

#12 1.402 authorization.go:7:2: package exotic/exotic-auth/security_helpers is not in std (/usr/local/go/src/exotic/exotic-auth/security_helpers)

#12 1.402 login.go:9:2: package exotic/exotic-auth/tasks is not in std (/usr/local/go/src/exotic/exotic-auth/tasks)

#12 1.402 found packages handlers (authorization.go) and tasks (deliver_email_task.go) in /app



#12 ERROR: process "/bin/sh -c CGO_ENABLED=0 GOOS=linux go build -o /server" did not complete successfully: exit code: 1
#12 [6/6] RUN CGO_ENABLED=0 GOOS=linux go build -o /server



#12 1.402 authorization.go:6:2: package exotic/exotic-auth/db/chat_users_db/model is not in std (/usr/local/go/src/exotic/exotic-auth/db/chat_users_db/model)

#12 1.402 main.go:5:2: package exotic/exotic-auth/handlers is not in std (/usr/local/go/src/exotic/exotic-auth/handlers)

#12 1.402 authorization.go:7:2: package exotic/exotic-auth/security_helpers is not in std (/usr/local/go/src/exotic/exotic-auth/security_helpers)

#12 1.402 login.go:9:2: package exotic/exotic-auth/tasks is not in std (/usr/local/go/src/exotic/exotic-auth/tasks)

#12 1.402 found packages handlers (authorization.go) and tasks (deliver_email_task.go) in /app



#12 ERROR: process "/bin/sh -c CGO_ENABLED=0 GOOS=linux go build -o /server" did not complete successfully: exit code: 1
254 Replies
Percy
Percy9mo ago
Project ID: dd3f96f7-3ab3-4453-86a3-32328b2f81d6
macwilko
macwilko9mo ago
dd3f96f7-3ab3-4453-86a3-32328b2f81d6
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
i'm probably being dumb
Brody
Brody9mo ago
hold on, whats with the atoi for on the redis env?
macwilko
macwilko9mo ago
total go nooby that's the database I think /0 i think usually
Brody
Brody9mo ago
Atoi turns a string into an int
root
root9mo ago
Can you use Nixpacks?
macwilko
macwilko9mo ago
yup, those ENV vars always strings right i would but... it's on an ancient Go version
root
root9mo ago
Ah, fair pretty sure you shouldn't use atoi for the redis db though
Brody
Brody9mo ago
yeah why are you trying to convert the database url into an int?
root
root9mo ago
You have all of your dependencies listed in your go.mod, right?
macwilko
macwilko9mo ago
sorry those ENV vars are mostly fine for my local dev, I'll have to change them around when I get it compiling for Railway
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
kinda looks like that locally
root
root9mo ago
I'd just use the REDIS_URL
Brody
Brody9mo ago
bruh, my bad i was reading REDIS_DB as REDIS_URL couldnt figure out what the hell you where doing
macwilko
macwilko9mo ago
ahah, I'll fix that, tbh it looks bad
root
root9mo ago
like so
No description
macwilko
macwilko9mo ago
ooo
root
root9mo ago
what happened to my newlines
macwilko
macwilko9mo ago
that looks nice
root
root9mo ago
No description
root
root9mo ago
there we go hollup
macwilko
macwilko9mo ago
how did you manage this terminal prompt?
Brody
Brody9mo ago
thats not any better lol
root
root9mo ago
Ray.so - Create beautiful images of your code
Turn your code into beautiful images. Choose from a range of syntax colors, hide or show the background, and toggle between a dark and light window.
macwilko
macwilko9mo ago
fancy
root
root9mo ago
THE NEWLINES EXIST IN MY BROWSER I SWEAR I TOOK A SCREENSHOT OF IT oh wait hold on i'm dumb
macwilko
macwilko9mo ago
😄
root
root9mo ago
No description
root
root9mo ago
there we go
macwilko
macwilko9mo ago
Well i feel in great company with learning Go now 😄 thanks!
Brody
Brody9mo ago
okay back to the main problem, whats this exotic auth thing
macwilko
macwilko9mo ago
ok this service is what will power the initial screen....
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
it's basically gonna be a central server that will create a community, and then register it in a database, it'll then spin up a server on railway
root
root9mo ago
nitpick: I feel like the I agree checkbox should be a checkbox instead of a radiobutton
macwilko
macwilko9mo ago
oo yes, should be 😄 so i have this auth thingy working locally, but just wanted to test it running on a real server
root
root9mo ago
Ah!
Brody
Brody9mo ago
so locally where is exotic/exotic-auth/handlers?
macwilko
macwilko9mo ago
then I'm gonna start playing with the GraphQL api to create a server
root
root9mo ago
You need to have a URL-based package name like github.com/macwilko/exotic/exotic-auth
Brody
Brody9mo ago
not always
root
root9mo ago
Otherwise it treats it as part of the stdlib, right?
macwilko
macwilko9mo ago
No description
root
root9mo ago
What's the name specified in your go.mod?
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
should I change that?
root
root9mo ago
Try changing that, yeah Generally change it to the URL of the git repository
Brody
Brody9mo ago
try to just exotic
root
root9mo ago
don't do what brody says that's advice for a normal go file, not go.mod
Brody
Brody9mo ago
i have never needed a url in my go.mod file
root
root9mo ago
🤷‍♂️
No description
macwilko
macwilko9mo ago
No description
root
root9mo ago
yes try that
macwilko
macwilko9mo ago
ok
0.860 authorization.go:9:2: no required module provides package github.com/macwilko/exotic-auth/db/chat_users_db/model; to add it:

0.860 go get github.com/macwilko/exotic-auth/db/chat_users_db/model
0.860 authorization.go:9:2: no required module provides package github.com/macwilko/exotic-auth/db/chat_users_db/model; to add it:

0.860 go get github.com/macwilko/exotic-auth/db/chat_users_db/model
root
root9mo ago
Do you have the db/chat_users_db/model directory in your project? Or is that a separate module?
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
yes it's a directory
root
root9mo ago
huh
macwilko
macwilko9mo ago
weird right >.< I always seem to mess up build tools
Brody
Brody9mo ago
so to be clear, yes use a url in the go.mod file if you are developing a module that will be imported by other go apps, but you arent doing that, this is the app itself, it does not need to have a url in the go.mod file
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
guys... omg im dumb it was a got dang issues with the files copy the COPY command wasn't copying those files that were flagged as erroring lol my bad >.< thankyou for the help both of you
Brody
Brody9mo ago
now do a multistage image
macwilko
macwilko9mo ago
O.O @Brody sorry one last thing... DB_SERVER_URL="root:Password123@tcp(127.0.0.1:3306)/chat_users_db?parseTime=true" this was a oddity ... for MySQL i had to specify tcp() this works locally on my server on the machine at home but on railway it's giving an error 2023/10/25 17:31:45 ERROR Unable to connect to db 2023/10/25 17:31:45 ERROR dial tcp: lookup mysql.railway.internal on 8.8.8.8:53: no such host panic: dial tcp: lookup mysql.railway.internal on 8.8.8.8:53: no such host I modified the URL to be ...
root:password@tcp(mysql.railway.internal:3306)/railway?parseTime=true
root:password@tcp(mysql.railway.internal:3306)/railway?parseTime=true
wow after I removed the TCP proxy it worked O.O (in the database settings on Railway)
Brody
Brody9mo ago
yeah the drivers want a dsn, railway only provides a url
macwilko
macwilko9mo ago
gotcha ok app says its running
macwilko
macwilko9mo ago
No description
Brody
Brody9mo ago
and the failed lookup, the private networks dns resolver is not available until about 2 seconds
macwilko
macwilko9mo ago
exotic-auth-production.up.railway.app but not getting through, probably the PORT is wrong I hard coded the app to be on 3000 right 😄
Brody
Brody9mo ago
addr := ":3000"

if envPort := os.Getenv("PORT"); envPort != "" {
addr = ":" + envPort
}

app.Listen(addr)
addr := ":3000"

if envPort := os.Getenv("PORT"); envPort != "" {
addr = ":" + envPort
}

app.Listen(addr)
macwilko
macwilko9mo ago
perfect its weird Railway doesn't add that to the variables
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
you'd think PORT is added here
Brody
Brody9mo ago
its generated behind the scenes and changes every deployment
Brody
Brody9mo ago
0.1% cpu usage? does railway agree with that?
macwilko
macwilko9mo ago
apparently lol no
Brody
Brody9mo ago
railway says 0.0 right?
macwilko
macwilko9mo ago
yeah
Brody
Brody9mo ago
okay cool
macwilko
macwilko9mo ago
what does your response time say? you're in canada right?
Medim
Medim9mo ago
cool metrics also, huge available ram
macwilko
macwilko9mo ago
it's from gogiber 😄
Medim
Medim9mo ago
dayum
No description
macwilko
macwilko9mo ago
yup
Brody
Brody9mo ago
its around 100ms
macwilko
macwilko9mo ago
ok
Medim
Medim9mo ago
cryingman
No description
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
would be cool if Railway could use the private url if the database isn't exposed
Brody
Brody9mo ago
i wouldnt worry about it, the data tab is flakey at best
macwilko
macwilko9mo ago
😦 fair
Brody
Brody9mo ago
why mysql tho
macwilko
macwilko9mo ago
i'll probably need to expose it though right, otherwise I'm not really able to expose it
Brody
Brody9mo ago
doesnt mysql use 500mb of mem on idle?
macwilko
macwilko9mo ago
i like boring tech for data things. Less surprises 😄
Brody
Brody9mo ago
fair, ill change my question, why mysql over postgres
macwilko
macwilko9mo ago
honestly it's just I'm a little more familiar with it i didn't see an especially good reason to learn postgres
Brody
Brody9mo ago
mariadb 🙂
macwilko
macwilko9mo ago
right
Brody
Brody9mo ago
doesnt use as much mem as mysql, but not as little as postgres
macwilko
macwilko9mo ago
how much is postgres out of curiousity?
Brody
Brody9mo ago
and i have a nice template for mariadb 🙂
macwilko
macwilko9mo ago
i guess the biggest cost running free chat servers will be the database, good point
Brody
Brody9mo ago
so how are you handling the dsn database variable?
macwilko
macwilko9mo ago
hold on a sec, I'll see if I can answer that AI is processing your answer
Brody
Brody9mo ago
why dont you just answer the question lol
macwilko
macwilko9mo ago
I think i'll keep it public
Brody
Brody9mo ago
the database?
macwilko
macwilko9mo ago
yeah
Brody
Brody9mo ago
why
macwilko
macwilko9mo ago
I won't be able to connect to it otherwise (outside of the app)
Brody
Brody9mo ago
gotcha but how are you giving your code the dsn string?
Medim
Medim9mo ago
make it private just in prod salute thats what i do
macwilko
macwilko9mo ago
how are you gonna fix problems to users if you can't modify the databse?
Brody
Brody9mo ago
build tooling to do that
Medim
Medim9mo ago
don't let users have problems in prod AUGH
macwilko
macwilko9mo ago
is that neccisary though? I mean my PlanetScale database is public, how can someone hack your database? The passwords are so long it's impossible to brute force
Medim
Medim9mo ago
better be safe than sorry
Brody
Brody9mo ago
but my question mac 😦
macwilko
macwilko9mo ago
i'm doing a string replace atm, so manually adding the tcp() bit lol
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
my smooth 🧠
Brody
Brody9mo ago
just make a referenceable dsn variable, set this in the database's service variables and then referance this in your service
MYSQL_PRIVATE_DSN=mysql://${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}
MYSQL_PRIVATE_DSN=mysql://${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}
macwilko
macwilko9mo ago
that works I'll try that one sec
Brody
Brody9mo ago
was that a question or a statement
macwilko
macwilko9mo ago
statement that'll make it much easier to build the template thingy ok everything seems to be working good now... next task is to use the Railway GraphQL API from the Auth server, to create a new project with some services and such
macwilko
macwilko9mo ago
alright 😄 thx! oh, right, back to the original problem though... connecting via tcp() with the internal address seems to fail?
macwilko
macwilko9mo ago
should I use udp or something?
Brody
Brody9mo ago
fail with that 8.8.8.8 dns error?
macwilko
macwilko9mo ago
yes if you remove the tcp proxy it works, but I don't wanna do that, otherwise I can't access the database from home (outside of railway)
Brody
Brody9mo ago
you are using github.com/go-sql-driver/mysql right?
macwilko
macwilko9mo ago
yep
Brody
Brody9mo ago
add a time.Sleep(5 * time.Second) before the sql.Open
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
right ok adding a sleep, one sec
Brody
Brody9mo ago
are you using an alpine image to run your app in?
macwilko
macwilko9mo ago
# syntax=docker/dockerfile:1

FROM golang:1.21
# syntax=docker/dockerfile:1

FROM golang:1.21
strange
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
different error now
${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}
${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}
macwilko
macwilko9mo ago
No description
Brody
Brody9mo ago
side question, you are missing the schema there??
macwilko
macwilko9mo ago
at least from what I've seen in sqlx, this is the right way
macwilko
macwilko9mo ago
Gist
Go mysql sqlx example
Go mysql sqlx example. GitHub Gist: instantly share code, notes, and snippets.
Brody
Brody9mo ago
okay ill see what i can do, since i have had no issues with just database/sql
macwilko
macwilko9mo ago
right >.< thankyou yeah that's weird... I'de prefer to use sqlx because plain sql makes things much harder (no sql injection protection for bindvars)
Brody
Brody9mo ago
wouldnt it be funny if i upload this test code and see no issues (im testing with sqlx.Connect)
macwilko
macwilko9mo ago
going to try socket() instead of tcp()
macwilko
macwilko9mo ago
No description
Brody
Brody9mo ago
okay its not just you
| MYSQL_PRIVATE_URL | mysql.railway.internal | mysql | Error | sql.Open error: dial tcp | 3.097963115s |
| | | | | [fd12:5e83:1f04::25:ff4:c6be]:3306: | |
| | | | | connect: connection refused | |
| MYSQL_PRIVATE_URL | mysql.railway.internal | mysql | Error | sql.Open error: dial tcp | 3.097963115s |
| | | | | [fd12:5e83:1f04::25:ff4:c6be]:3306: | |
| | | | | connect: connection refused | |
macwilko
macwilko9mo ago
yeah 😦 i'm not barking mad promise 😄
Brody
Brody9mo ago
okay but why would sqlx require a different format, thats just frustrating
macwilko
macwilko9mo ago
https://dev.mysql.com/doc/refman/8.0/en/transport-protocols.html i know... it's weird i was wondering if anyone of those would help hmm i might try omit the tcp bit entirely maybe nope 😦
Brody
Brody9mo ago
is your database sleeping?
macwilko
macwilko9mo ago
nope
Brody
Brody9mo ago
i only got that error since the databases where sleeping, once they are awake i cant reproduce
macwilko
macwilko9mo ago
oh is your url like this:
${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}
${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}
Brody
Brody9mo ago
though i am using github.com/xo/dburl to turn the regular database url environment variable into a dsn
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
can you share that code please ^.^ never even heard of a DSN until today lol
Brody
Brody9mo ago
dsn, _ := dburl.Parse("<url>")

fmt.Println(dsn.DSN)
dsn, _ := dburl.Parse("<url>")

fmt.Println(dsn.DSN)
macwilko
macwilko9mo ago
actually my URL is
${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}?parseTime=true
${{MYSQLUSER}}:${{MYSQL_ROOT_PASSWORD}}@tcp(${{RAILWAY_PRIVATE_DOMAIN}}:3306)/${{MYSQL_DATABASE}}?parseTime=true
Although I doubt that makes much difference
Brody
Brody9mo ago
this code prints the same dsn that reference variable would render to
macwilko
macwilko9mo ago
sorry brody do you mind sharing: the ENV var you're using the lines that involve sqlx.Connect?
macwilko
macwilko9mo ago
No description
Brody
Brody9mo ago
using 100% default database url env vars for both the public and private version of that env
macwilko
macwilko9mo ago
right
Brody
Brody9mo ago
code, one sec
macwilko
macwilko9mo ago
DATABASE_URL=${{MySQL.MYSQL_PRIVATE_URL}}
Brody
Brody9mo ago
yep thats what im doing, i havent modified any variables on the database services
macwilko
macwilko9mo ago
sounds good, will make it easier too... i guess I just assumed the tcp was needed didn't know about the DSN bit
Brody
Brody9mo ago
it is dsn.DSN will wrap the host:port in tcp()
macwilko
macwilko9mo ago
i see
Brody
Brody9mo ago
for the mysql driver that is needed
macwilko
macwilko9mo ago
woo connected works wtf does it do differently that's so weird
Brody
Brody9mo ago
sqlx.Connect just calls sql.Open with the same driver name and data source name passed into it, so sqlx wasnt the problem
macwilko
macwilko9mo ago
hmm, one thing is it seems to omit the parseTime=true I need to check if the databsae works without that
Brody
Brody9mo ago
then add it back
query := dsn.Query()

query.Set("connect_timeout", "5")
query.Set("timeout", "5")

dsn.RawQuery = query.Encode()
query := dsn.Query()

query.Set("connect_timeout", "5")
query.Set("timeout", "5")

dsn.RawQuery = query.Encode()
this is the code i have been using https://github.com/brody192/database-connection-tester/blob/main/internal/dbtest/databases/sql.go#L16-L30
macwilko
macwilko9mo ago
oo brody you are intense
Brody
Brody9mo ago
🙂
No description
macwilko
macwilko9mo ago
idk how many support engineers go into this level of detail lol
Brody
Brody9mo ago
they all do
macwilko
macwilko9mo ago
guess so, salute
Brody
Brody9mo ago
i used this setup to find out that the mongodb template railway offered didnt listen on ipv6 and ipv4 by default, only ipv4
macwilko
macwilko9mo ago
🙂 yeah you're essentially automating all the testing I guess
Brody
Brody9mo ago
cute little print out
Starting 12 Tests...
+-----------------------+----------------------------+----------+---------+-------+--------------+
| ENV | Host | Scheme | Status | Error | Duration |
+-----------------------+----------------------------+----------+---------+-------+--------------+
| MARIADB_PRIVATE_URL | mariadb.railway.internal | mariadb | Success | N/A | 7.498273ms |
| REDIS_PRIVATE_URL | redis.railway.internal | redis | Success | N/A | 8.496766ms |
| DRAGONFLY_PRIVATE_URL | dragonfly.railway.internal | redis | Success | N/A | 10.852575ms |
| DRAGONFLY_PUBLIC_URL | roundhouse.proxy.rlwy.net | redis | Success | N/A | 11.62038ms |
| MARIADB_PUBLIC_URL | monorail.proxy.rlwy.net | mariadb | Success | N/A | 13.966628ms |
| REDIS_PUBLIC_URL | monorail.proxy.rlwy.net | redis | Success | N/A | 14.615561ms |
| POSTGRES_PRIVATE_URL | postgres.railway.internal | postgres | Success | N/A | 19.508288ms |
| MONGO_PRIVATE_URL | mongodb.railway.internal | mongodb | Success | N/A | 20.859384ms |
| MONGO_PUBLIC_URL | monorail.proxy.rlwy.net | mongodb | Success | N/A | 22.994126ms |
| POSTGRES_PUBLIC_URL | monorail.proxy.rlwy.net | postgres | Success | N/A | 25.561527ms |
| MYSQL_PUBLIC_URL | viaduct.proxy.rlwy.net | mysql | Success | N/A | 1.88047089s |
| MYSQL_PRIVATE_URL | mysql.railway.internal | mysql | Success | N/A | 3.041569359s |
+-----------------------+----------------------------+----------+---------+-------+--------------+
| Total | 3.042123138s |
+-----------------------+----------------------------+----------+---------+-------+--------------+
Starting 12 Tests...
+-----------------------+----------------------------+----------+---------+-------+--------------+
| ENV | Host | Scheme | Status | Error | Duration |
+-----------------------+----------------------------+----------+---------+-------+--------------+
| MARIADB_PRIVATE_URL | mariadb.railway.internal | mariadb | Success | N/A | 7.498273ms |
| REDIS_PRIVATE_URL | redis.railway.internal | redis | Success | N/A | 8.496766ms |
| DRAGONFLY_PRIVATE_URL | dragonfly.railway.internal | redis | Success | N/A | 10.852575ms |
| DRAGONFLY_PUBLIC_URL | roundhouse.proxy.rlwy.net | redis | Success | N/A | 11.62038ms |
| MARIADB_PUBLIC_URL | monorail.proxy.rlwy.net | mariadb | Success | N/A | 13.966628ms |
| REDIS_PUBLIC_URL | monorail.proxy.rlwy.net | redis | Success | N/A | 14.615561ms |
| POSTGRES_PRIVATE_URL | postgres.railway.internal | postgres | Success | N/A | 19.508288ms |
| MONGO_PRIVATE_URL | mongodb.railway.internal | mongodb | Success | N/A | 20.859384ms |
| MONGO_PUBLIC_URL | monorail.proxy.rlwy.net | mongodb | Success | N/A | 22.994126ms |
| POSTGRES_PUBLIC_URL | monorail.proxy.rlwy.net | postgres | Success | N/A | 25.561527ms |
| MYSQL_PUBLIC_URL | viaduct.proxy.rlwy.net | mysql | Success | N/A | 1.88047089s |
| MYSQL_PRIVATE_URL | mysql.railway.internal | mysql | Success | N/A | 3.041569359s |
+-----------------------+----------------------------+----------+---------+-------+--------------+
| Total | 3.042123138s |
+-----------------------+----------------------------+----------+---------+-------+--------------+
macwilko
macwilko9mo ago
well good job deploys are about ~1 minute now and not 10 minutes ooo
Brody
Brody9mo ago
10 minutes??
macwilko
macwilko9mo ago
nice to see MySQL connects the fastest 😄 Yeah... the ruby build process is slow af
Brody
Brody9mo ago
i think mysql was sleeping at that time heres a test where all dbs are awake
Starting 12 Tests...
+-----------------------+----------------------------+----------+---------+-------+-------------+
| ENV | Host | Scheme | Status | Error | Duration |
+-----------------------+----------------------------+----------+---------+-------+-------------+
| MARIADB_PUBLIC_URL | monorail.proxy.rlwy.net | mariadb | Success | N/A | 7.969834ms |
| MARIADB_PRIVATE_URL | mariadb.railway.internal | mariadb | Success | N/A | 8.905264ms |
| REDIS_PUBLIC_URL | monorail.proxy.rlwy.net | redis | Success | N/A | 9.064799ms |
| DRAGONFLY_PUBLIC_URL | roundhouse.proxy.rlwy.net | redis | Success | N/A | 10.875556ms |
| MYSQL_PUBLIC_URL | viaduct.proxy.rlwy.net | mysql | Success | N/A | 10.797191ms |
| MYSQL_PRIVATE_URL | mysql.railway.internal | mysql | Success | N/A | 12.232928ms |
| DRAGONFLY_PRIVATE_URL | dragonfly.railway.internal | redis | Success | N/A | 13.565742ms |
| REDIS_PRIVATE_URL | redis.railway.internal | redis | Success | N/A | 11.709066ms |
| POSTGRES_PUBLIC_URL | monorail.proxy.rlwy.net | postgres | Success | N/A | 22.98597ms |
| POSTGRES_PRIVATE_URL | postgres.railway.internal | postgres | Success | N/A | 24.28533ms |
| MONGO_PRIVATE_URL | mongodb.railway.internal | mongodb | Success | N/A | 25.718863ms |
| MONGO_PUBLIC_URL | monorail.proxy.rlwy.net | mongodb | Success | N/A | 26.869439ms |
+-----------------------+----------------------------+----------+---------+-------+-------------+
| Total | 28.487027ms |
+-----------------------+----------------------------+----------+---------+-------+-------------+
Starting 12 Tests...
+-----------------------+----------------------------+----------+---------+-------+-------------+
| ENV | Host | Scheme | Status | Error | Duration |
+-----------------------+----------------------------+----------+---------+-------+-------------+
| MARIADB_PUBLIC_URL | monorail.proxy.rlwy.net | mariadb | Success | N/A | 7.969834ms |
| MARIADB_PRIVATE_URL | mariadb.railway.internal | mariadb | Success | N/A | 8.905264ms |
| REDIS_PUBLIC_URL | monorail.proxy.rlwy.net | redis | Success | N/A | 9.064799ms |
| DRAGONFLY_PUBLIC_URL | roundhouse.proxy.rlwy.net | redis | Success | N/A | 10.875556ms |
| MYSQL_PUBLIC_URL | viaduct.proxy.rlwy.net | mysql | Success | N/A | 10.797191ms |
| MYSQL_PRIVATE_URL | mysql.railway.internal | mysql | Success | N/A | 12.232928ms |
| DRAGONFLY_PRIVATE_URL | dragonfly.railway.internal | redis | Success | N/A | 13.565742ms |
| REDIS_PRIVATE_URL | redis.railway.internal | redis | Success | N/A | 11.709066ms |
| POSTGRES_PUBLIC_URL | monorail.proxy.rlwy.net | postgres | Success | N/A | 22.98597ms |
| POSTGRES_PRIVATE_URL | postgres.railway.internal | postgres | Success | N/A | 24.28533ms |
| MONGO_PRIVATE_URL | mongodb.railway.internal | mongodb | Success | N/A | 25.718863ms |
| MONGO_PUBLIC_URL | monorail.proxy.rlwy.net | mongodb | Success | N/A | 26.869439ms |
+-----------------------+----------------------------+----------+---------+-------+-------------+
| Total | 28.487027ms |
+-----------------------+----------------------------+----------+---------+-------+-------------+
12 tests all done at the same time in under 30ms
macwilko
macwilko9mo ago
3s 😦
Brody
Brody9mo ago
3s from sleep
macwilko
macwilko9mo ago
right 😉 gotcha so basically every query to the database is minimum 12ms?
Brody
Brody9mo ago
those are connection times, queries would be far faster at least the connection rtt would be, not accounting for actual the time it takes to do the query on the database itself
macwilko
macwilko9mo ago
sec just seeing if I can fix this salute
Brody
Brody9mo ago
bugs are fun
macwilko
macwilko9mo ago
i live for the bugs
macwilko
macwilko9mo ago
we're in business, everything working so I figure to keep it more affordable, makes sense to have seperate databases probably a Pro feature. I'll make it so free servers spin up their own little go api but connect to the same database and then the Pro or Self hosted options can have dedicated resources
Brody
Brody9mo ago
use sqlite in a volume 🙂
macwilko
macwilko9mo ago
oo maybe lol, that would be neat and really affordable to run i mean what's the trade offs there? won't sqlite be very slow to access?
Brody
Brody9mo ago
disk accessed databases would be faster than network accessed databases it's closer and all that
macwilko
macwilko9mo ago
true
Brody
Brody9mo ago
and railways volumes are very fast
macwilko
macwilko9mo ago
i guess its the locking of the database that's the issue for sqlite interesting
Brody
Brody9mo ago
sqlite handles that stuff doesn't it?
macwilko
macwilko9mo ago
well, tbf that's a good thing to look into, and does change the game in terms of performance / cost
Brody
Brody9mo ago
the only cost for sqlite would be the cost of the volume
macwilko
macwilko9mo ago
right yeah that's basically nothing ok so a typical server might have, what, 500 people in max? so could an sqlite database handle 500 or so active partipants in a given server, writing occasionally to update their last_seen_at time and maybe post a message in a channel every often remember because chat servers are inherently write heavy
SQLite supports an unlimited number of simultaneous readers, but it will only allow one writer at any instant in time.
SQLite supports an unlimited number of simultaneous readers, but it will only allow one writer at any instant in time.
single writer
Brody
Brody9mo ago
a single writer for any data anywhere on the database, or just a single writer per table?
macwilko
macwilko9mo ago
Brody
Brody9mo ago
you did just say writing occasionally
macwilko
macwilko9mo ago
SQLite only supports one writer at a time per database file. i mean, it could easily be there's many writers think about when a couple of people are typing in a channel and there's 20 odd channels one one person will be able to write at a time 😦
Brody
Brody9mo ago
conclusion, use postgres 🙂
macwilko
macwilko9mo ago
heh shame honestly, I'd wish sqlite would work well just thinking about this. there's very little benefit deploying dedicated databases per server. So I can stick with one database, but many replica's of the Go api (for websockets / api calls etc). The only people needing a dedicated DB are enterprise users and they'll use a self hosted option anyway.
Brody
Brody9mo ago
okay then use a different document database
macwilko
macwilko9mo ago
lol why do you dislike mysql so much lol it's fine
Brody
Brody9mo ago
postgres is still sql
root
root9mo ago
Do yourself a favor, don't use a document database
macwilko
macwilko9mo ago
oh yeah, for sure won't be 😄
Brody
Brody9mo ago
sqlite is a document database? no?
root
root9mo ago
no
macwilko
macwilko9mo ago
alrighty, time to get myself all dirty and get familiar with Railway GraphQL sqlite is like, sql but liter 😄
Brody
Brody9mo ago
I'm just calling on disk databases a document database my bad
macwilko
macwilko9mo ago
no worries
Brody
Brody9mo ago
okay so use a different on disk database?
macwilko
macwilko9mo ago
i'm guessing its a blob of data with lots of smart ways to efficiently index and lookup data hmm, are there any other good options? i think sqlite is the only on-disk database that offers sql like features I've heard of but anyway, I think I've concluded, there's not much cost/benefit to seperate the db for free servers. i can run a single mysql db for those users no issue, and then pro/self hosted options can use their own db if I get issues with the railway database I can switch over to planetscale later
Brody
Brody9mo ago
woohoo pog
macwilko
macwilko9mo ago
is that what your concern is I guess the resiliancy of the databases
Brody
Brody9mo ago
brain empty no concerns found
macwilko
macwilko9mo ago
phew your brain is becoming a beautiful almond
Brody
Brody9mo ago
almonds are too bumpy
Brody
Brody9mo ago
lmao
macwilko
macwilko9mo ago
ok dumb question, but what if I have another Dockerfile in my project like Dockerfile.scheduler can I have railway build that instead?
Brody
Brody9mo ago
sure can (not a dumb question by any means) https://docs.railway.app/develop/variables#user-provided-configuration-variables
RAILWAY_DOCKERFILE_PATH=Dockerfile.scheduler
RAILWAY_DOCKERFILE_PATH=Dockerfile.scheduler
macwilko
macwilko9mo ago
amazing
:46:42 ERROR Redis Error

2023/10/25 21:46:42 ERROR dial tcp [::1]:6379: connect: connection refused
:46:42 ERROR Redis Error

2023/10/25 21:46:42 ERROR dial tcp [::1]:6379: connect: connection refused
argh i think it's a bug with Shared variables
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
I added this as a shared variable but then in the service the RAILWAY_PRIVATE_DOMAIN is missing
macwilko
macwilko9mo ago
No description
macwilko
macwilko9mo ago
I also don't see it here i don't have the patience to fix this right now, gonna leave it as it is gotta get other stuff working lol
Brody
Brody9mo ago
not a bug, just simply not how that works remove it from the shared variables, and add it to the redis service
macwilko
macwilko9mo ago
i mean i appear to be missing the private url in redis
Brody
Brody9mo ago
yes, add it back
macwilko
macwilko9mo ago
oh
Brody
Brody9mo ago
it never had one to begin with I can promise you that
macwilko
macwilko9mo ago
i see