Setting up mono-repo

Been trying to connect my IONOS domain to my deployment. Has anyone connected IONOS domains properly ? I've seen some inconclusive threads and something about requiring a proxy for IONOS. Thank you all in advance. @Brody
626 Replies
Percy
Percy2y ago
Project ID: 740bdf7f-248a-4096-9001-688bbb7a239e
nex1560
nex15602y ago
740bdf7f-248a-4096-9001-688bbb7a239e
Brody
Brody2y ago
you will have to use cloudflares nameservers (you dont need to transfer your domain)
Brody
Brody2y ago
just use their nameservers, they make it very easy to switch, they will scan and transfer all your current dns settings
nex1560
nex15602y ago
Thank you, I will look into it
Brody
Brody2y ago
nex1560
nex15602y ago
Thank you, already adding site at the moment, just a quick question about this Is it respective to how many pages my application has or something ? I have a django react application so single page ? 🙂 Thank you very much
Brody
Brody2y ago
oh no that has nothing to do with the routes in your app, thats for things like forwarding non-www to www
nex1560
nex15602y ago
Ok cool got it
Brody
Brody2y ago
huh
nex1560
nex15602y ago
Sorry I thought that was the last step but it isn't looking at changing nameservers I won't need an SSL from them as Railway already has an SSL correct ?
Brody
Brody2y ago
correct
nex1560
nex15602y ago
Thank you very much Brody, you made it very smooth
Brody
Brody2y ago
no problem, are you all good?
nex1560
nex15602y ago
For this issue yeah xD I now need to find a workaround my SMTP issue in order to keep the deployment on Railway Any suggestions ?
Brody
Brody2y ago
are you trying to run an SMTP server on railway?
nex1560
nex15602y ago
I send emails from my django backend app for registration/forgotten password/ order confirmations and updates, don't know if that's running an SMTP server, guess it is ?
Brody
Brody2y ago
no its not, there shouldn't be a problem with that what seems to be the problem?
nex1560
nex15602y ago
Well, emails aren't sending And I get internal errror 500
Brody
Brody2y ago
well yeah lol
nex1560
nex15602y ago
I have seen other threads on this lol sorry
Brody
Brody2y ago
youd need credential stuff to send an email, are you adding those credentials to your railway service variables and then using them in your code?
nex1560
nex15602y ago
From looking at my deployment logs I suspect my installation (Dockerfile) is wrong, I have the following -> File "/app/base/signals.py", line 84, in send_order_confirmation_email email.send(fail_silently=False) File "/opt/venv/lib/python3.10/site-packages/django/core/mail/message.py", line 298, in send return self.get_connection(fail_silently).send_messages([self]) File "/opt/venv/lib/python3.10/site-packages/django/core/mail/message.py", line 255, in get_connection self.connection = get_connection(fail_silently=fail_silently) File "/opt/venv/lib/python3.10/site-packages/django/core/mail/init.py", line 50, in get_connection klass = import_string(backend or settings.EMAIL_BACKEND) File "/opt/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string return cached_import(module_path, class_name) File "/opt/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import module = import_module(module_path) File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) (...) ModuleNotFoundError: No module named "'django"
Brody
Brody2y ago
send your dockerfile?
nex1560
nex15602y ago
nex1560
nex15602y ago
# Pull official base image
FROM python:3.10-slim-buster AS compile-image

# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
gcc \
curl \
python3-psycopg2 \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs

# Set work directory
WORKDIR /app

# Install pip requirements
COPY requirements.txt .
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy the Django application
COPY . .

# Build the React application
WORKDIR /app/frontend
RUN npm install && npm run build

# Go back to the Django application directory
WORKDIR /app

# Run migrations and collect static files
RUN python manage.py migrate && python manage.py collectstatic --noinput

# Command to run when starting your Docker container
CMD gunicorn backend.wsgi:application --bind 0.0.0.0:$PORT

# Clean up stage
FROM python:3.10-slim-buster AS build-image
RUN apt-get update && apt-get install -y --no-install-recommends libpq5
COPY --from=compile-image /opt/venv /opt/venv
COPY --from=compile-image /app /app

WORKDIR /app
ENV PATH="/opt/venv/bin:$PATH"

CMD gunicorn backend.wsgi:application --bind 0.0.0.0:$PORT
# Pull official base image
FROM python:3.10-slim-buster AS compile-image

# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
gcc \
curl \
python3-psycopg2 \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs

# Set work directory
WORKDIR /app

# Install pip requirements
COPY requirements.txt .
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy the Django application
COPY . .

# Build the React application
WORKDIR /app/frontend
RUN npm install && npm run build

# Go back to the Django application directory
WORKDIR /app

# Run migrations and collect static files
RUN python manage.py migrate && python manage.py collectstatic --noinput

# Command to run when starting your Docker container
CMD gunicorn backend.wsgi:application --bind 0.0.0.0:$PORT

# Clean up stage
FROM python:3.10-slim-buster AS build-image
RUN apt-get update && apt-get install -y --no-install-recommends libpq5
COPY --from=compile-image /opt/venv /opt/venv
COPY --from=compile-image /app /app

WORKDIR /app
ENV PATH="/opt/venv/bin:$PATH"

CMD gunicorn backend.wsgi:application --bind 0.0.0.0:$PORT
Brody
Brody2y ago
would you mind surounding all that text with triple back ticks
nex1560
nex15602y ago
Of course I was also trying to install psycop2g from requirements.txt however it wasn't working properly, and then I added it to apt get install and it fixed the issue So something is definetely wrong with my Dockerfile knowledge
Brody
Brody2y ago
that stuff looks do-able with nixpacks wanna share your repo so i could work on getting you a railway.json file so you can ditch your dockerfile?
nex1560
nex15602y ago
Ehmmm private repo Let me think What do you need more specifically ?
Brody
Brody2y ago
it would significantly help in taking out the guess work, kinda just wanna see a general overview of how stuff is layed out and whatnot
nex1560
nex15602y ago
Can I PM it to you ? Will make public for the meantime Aaaaactually hold on give me a sec
Brody
Brody2y ago
you can just add me to the repo?
nex1560
nex15602y ago
yeah sure
Brody
Brody2y ago
brody192
nex1560
nex15602y ago
Added
Brody
Brody2y ago
and it's now dinner time, so I will get back to you later
nex1560
nex15602y ago
I'll be doing the same Enjoy And thanks
Brody
Brody2y ago
im ready when you are
nex1560
nex15602y ago
Here
Brody
Brody2y ago
so what you have is a monorepo, thus it will typically require two seprate railway services
nex1560
nex15602y ago
Yup, I have a postgres and the deployment Is that what you mean ?
Brody
Brody2y ago
not quite postgre is a plugin
nex1560
nex15602y ago
Okay
Brody
Brody2y ago
so first things first, we will be modifying the repo a bunch and we dont need to waste railways resources building your app over and over until we are ready, so lets remove the repo temporarily remove it from your service please
nex1560
nex15602y ago
done
Brody
Brody2y ago
and then show me a screenshot of the project please
nex1560
nex15602y ago
Brody
Brody2y ago
quick question, you have a react app and a django app, what is the django app used for
nex1560
nex15602y ago
Django is the backend And react is built and linked in django
Brody
Brody2y ago
where is that setup
nex1560
nex15602y ago
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'frontend/build/static')] let me find it one sec
nex1560
nex15602y ago
nex1560
nex15602y ago
this is backend/urls.py Does that answer your question ?
Brody
Brody2y ago
yes, but how are the assets served like css and js
nex1560
nex15602y ago
oh whitenoise ? guinicorn
Brody
Brody2y ago
what about the react apps assets
nex1560
nex15602y ago
I'm afraid I don't understand the question, sorry As far as I know, as long as I runbuild it generates an index.html that I link django to and that's it
Brody
Brody2y ago
is django just an api?
nex1560
nex15602y ago
Yup django is pretty much just an API here it's also in between the react frontend app and the db
Brody
Brody2y ago
okay then we are gonna do something more conventional here, beacuse having django serve the frontend is a hack to say the least
nex1560
nex15602y ago
Hmmm well I'm listening
Brody
Brody2y ago
my plan, two railway services, one service for the frontend (react), and one service for the backend (django)
nex1560
nex15602y ago
I mean First react/django app here I followed some tutorials on this and this is how they were doing it I do understand it and it makes sense to me, your solution
Brody
Brody2y ago
usually i see people with a react frontend and a nodejs backend, but its always two services for frontend and backend and the two services is quite standard
nex1560
nex15602y ago
Yeah, I get it Should work
Brody
Brody2y ago
so lets do that
nex1560
nex15602y ago
Just don't know how to do it 😄
Brody
Brody2y ago
we will work though this together
nex1560
nex15602y ago
Because then I will also lose my routes to /admin I believe no ?
Brody
Brody2y ago
where is the /admin route defined
nex1560
nex15602y ago
Same place Here
Brody
Brody2y ago
django?
nex1560
nex15602y ago
here
Brody
Brody2y ago
you would just call that route from your frontend it will all make sense in time, trust the process
nex1560
nex15602y ago
Ok 😄
Brody
Brody2y ago
go ahead and remove the django code that serves the frontend remove the dockerfile too, id like to use railway's nixpacks for this
nex1560
nex15602y ago
If I make it
Brody
Brody2y ago
huh
nex1560
nex15602y ago
root and then frontend backend underneath is that good Or do you want just frontend in this repo
Brody
Brody2y ago
oh no, you can keep both things in this repo trust me
nex1560
nex15602y ago
ok I do Just wanted to understand what you wanted exactly 1 sec
Brody
Brody2y ago
you can push your changes to github so i can see and confirm everything is going accordingly
nex1560
nex15602y ago
Another 2 minutes Local shenanigans .. sry
Brody
Brody2y ago
understandable
nex1560
nex15602y ago
im a little confused here I moved the folder out
Brody
Brody2y ago
woah, i never said to do that
nex1560
nex15602y ago
HAHAHAH yeah one sec
Brody
Brody2y ago
i just wanted you to delete what the arrow pointed to
nex1560
nex15602y ago
Oooh
Brody
Brody2y ago
lol
nex1560
nex15602y ago
You didn't want to have root and under root have a frontend folder and a backend folder ?
Brody
Brody2y ago
Brody
Brody2y ago
is this what you where trying to do
nex1560
nex15602y ago
yes
Brody
Brody2y ago
oh then technically the frontend folder doesnt move
nex1560
nex15602y ago
but I messed up my origin Cause root folder of repo is root folder of the django application
Brody
Brody2y ago
i see you can always wipe that repo and start fresh once you fixed the folder structure locally
nex1560
nex15602y ago
yup doing that rn
Brody
Brody2y ago
what branch will you be working on going forward
nex1560
nex15602y ago
prod but I don't know why it's on master
Brody
Brody2y ago
github is hard frfr
nex1560
nex15602y ago
lmao
nex1560
nex15602y ago
nex1560
nex15602y ago
I'm literally on it in pycharm
Brody
Brody2y ago
pycharm kinda mid tbh vscode + github desktop is where its at
nex1560
nex15602y ago
I like pycharm for django support besides that yeah I'm on vscode also
Brody
Brody2y ago
im sure vscode has a plugin for it
nex1560
nex15602y ago
I spent a bunch of time and then I got tired of it, conflicts with linting and so on, definetely just me not setting things properly and not knowing how so ...
Brody
Brody2y ago
its tough out there
nex1560
nex15602y ago
ok I made another repo
Brody
Brody2y ago
whatever it takes lol
nex1560
nex15602y ago
what was your git ?
Brody
Brody2y ago
brody192
nex1560
nex15602y ago
added
Brody
Brody2y ago
do me a favour and remove me from your old repo
nex1560
nex15602y ago
yup done
Brody
Brody2y ago
your repo seems to be missing a lot of necessary django stuff
nex1560
nex15602y ago
oh yeah
Brody
Brody2y ago
oops
nex1560
nex15602y ago
Need to reconfigure stuff now fk
Brody
Brody2y ago
holler when done
nex1560
nex15602y ago
yessir So now the thing is
nex1560
nex15602y ago
nex1560
nex15602y ago
An example of a post request from react I feel like this is too broad of a scope that needs to be changed
Brody
Brody2y ago
I know since the django api will soon be a separate service, all you have to do is call the django service domain followed by that same path this is standard, whatever tutorial you followed lead you down the incorrect path I'm afraid and this is just what needs to be done to run your app on railway properly
nex1560
nex15602y ago
ok django runs locally one moment
Brody
Brody2y ago
I know it works locally I've heard that a million times
nex1560
nex15602y ago
😄
Brody
Brody2y ago
running locally and running on an online cloud are very different things
nex1560
nex15602y ago
No I meant like I separated them both and it's running
Brody
Brody2y ago
huh on railway??
nex1560
nex15602y ago
no
Brody
Brody2y ago
ah okay, let me know when your repo is ready for me to look
nex1560
nex15602y ago
ok should be good now was missing manage.py for some reason and requirements
Brody
Brody2y ago
true
nex1560
nex15602y ago
I also removed dockerfile
Brody
Brody2y ago
cool, will look in a sec I assume you have something like postman to test your api when it's live right?
nex1560
nex15602y ago
yes
Brody
Brody2y ago
whatcha got
nex1560
nex15602y ago
I have postman
Brody
Brody2y ago
question, why is the python verison in runtime.txt a negative value?
nex1560
nex15602y ago
isn't it supposed to look like that ? don't think Iwrote that file
Brody
Brody2y ago
im not aware of any negative python version lol
nex1560
nex15602y ago
LMAO
Brody
Brody2y ago
the contents of that file should only be
3.10
3.10
and it should be located in the backend folder while youre at it, move the procfile to the backend folder too in your requirements.txt file using psycopg2-binary instead of psycopg2 will result in much faster build times
nex1560
nex15602y ago
But isn't it not recommended for production ?
Brody
Brody2y ago
says who
nex1560
nex15602y ago
The internet lmao Idk Saw that in many places I'll change it
Brody
Brody2y ago
first ive heard that
nex1560
nex15602y ago
psycopg2-binary==2.9.6 this cool ?
Brody
Brody2y ago
yes and you are right
Brody
Brody2y ago
Brody
Brody2y ago
but if its not gonna tell me why, then i dont care, it speeds up build time
nex1560
nex15602y ago
Yo I need more people like you in my life
Brody
Brody2y ago
haha
nex1560
nex15602y ago
thanks changed it
Brody
Brody2y ago
looks good
nex1560
nex15602y ago
It's rought out there for a junior, especially in today's market
Brody
Brody2y ago
now, something i just wanna point out, but i will let you do in the future you are committing your .env file to your repo, this is not a good idea, even if its a private repo, you should be storing the credentials in your railway service variables
nex1560
nex15602y ago
Understood hmmmm I did do that However django didn't seem to get them the same way ?
Brody
Brody2y ago
it would
nex1560
nex15602y ago
nex1560
nex15602y ago
ok
Brody
Brody2y ago
okay i see well then lets tackle that now since you are 90% of the way there delete your .env file (but do a double check if you have everything stored in railway)
nex1560
nex15602y ago
Brody
Brody2y ago
yeah remove that too
nex1560
nex15602y ago
done
Brody
Brody2y ago
other people may tell you otherwise, but in my opinion storing your database password and stripe key in plaintext is not a good idea
nex1560
nex15602y ago
nw I get it
Brody
Brody2y ago
here you arent using the standard variable names, as they are in the railway variables https://github.com/BADIUDragos/annedora-2-prod/blob/prod/backend/backend/settings.py#L125 so here is an excample of using the correct variable names https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py#L81
nex1560
nex15602y ago
Okkk so just names
Brody
Brody2y ago
yea
nex1560
nex15602y ago
no need to do environ vs getenv ?
Brody
Brody2y ago
do what the official template does
nex1560
nex15602y ago
nex1560
nex15602y ago
nex1560
nex15602y ago
don't need this I suppose also I really really appreciate everything But I kinda have to call it for tonight Any chance you're available tomorrow or later ?
Brody
Brody2y ago
not sure tbh, don't know why you have another database object/dictionary elsewhere, leave it for now I guess 7 days a week
nex1560
nex15602y ago
You're a G All right Thank you soo much Have a good one and see you later
Brody
Brody2y ago
no problemo see ya later
nex1560
nex15602y ago
Brodyyy I fixed the settings for the DB as you said What's next ? @Brody
Brody
Brody2y ago
good question send me a link to your repo again
nex1560
nex15602y ago
done
Brody
Brody2y ago
do you have any build or start commands defined in your railway service?
nex1560
nex15602y ago
No, this was all done with the dockerfile, which you told me to ditch
Brody
Brody2y ago
good any variables?
nex1560
nex15602y ago
yes
nex1560
nex15602y ago
Brody
Brody2y ago
oh yeah rename that service to something like annedora-prod-backend
nex1560
nex15602y ago
ok
Brody
Brody2y ago
since those are all variables for your backend show me your domains for that service?
nex1560
nex15602y ago
nex1560
nex15602y ago
cloudfare is good, since yesterday
nex1560
nex15602y ago
nex1560
nex15602y ago
renamed
Brody
Brody2y ago
now that is obviously the domain you want to access your frontend from, so remove it from this service then go ahead and setup an api.annedora.ca or something similar, you get the idea
nex1560
nex15602y ago
Can I just leave this as the frontend and make a new service ? Cause it was already configured for frontend
Brody
Brody2y ago
that means you have to move all the variables over, it doesnt matter to me, i just thought updating the domain would be easier
nex1560
nex15602y ago
ah ok true
Brody
Brody2y ago
okay so let me know when you have that sorted
nex1560
nex15602y ago
so basically rename this to api.annedora.ca and same thing in the service, than make another cname here for a new empty service, correct ?
nex1560
nex15602y ago
Brody
Brody2y ago
1. delete both the railway generated domain and the custom domain from the railway service settings 2. generate a new railway domain, make sure its named appropriately 3. delete the root level cname domains from railway 4. add api.annedora.ca to your railway domains 5. use the cname railway gives you to make your api subdomain in cloudflare
nex1560
nex15602y ago
nex1560
nex15602y ago
Brody
Brody2y ago
missed step 2, im not sure its 100% necessary, but ive seen people have troubles using only a custom domain
nex1560
nex15602y ago
nex1560
nex15602y ago
understood
Brody
Brody2y ago
i think its time to deploy your backend first set the root directory to /backend then you add your repo back wait
nex1560
nex15602y ago
Brody
Brody2y ago
does django need to run migrations?
nex1560
nex15602y ago
the db is already populated
Brody
Brody2y ago
cool
nex1560
nex15602y ago
should be fine
Brody
Brody2y ago
famous last words
nex1560
nex15602y ago
lmao Yeah ... been there done that xD
Brody
Brody2y ago
well let me know how the deploy goes
nex1560
nex15602y ago
nex1560
nex15602y ago
I'll try switching back to getenv
Brody
Brody2y ago
nooo slow down
nex1560
nex15602y ago
oke
Brody
Brody2y ago
you are using environ with the bendy brackets () you need to use square brackets []
nex1560
nex15602y ago
nex1560
nex15602y ago
should I move this into the first declaration above
nex1560
nex15602y ago
Ah ok cool
nex1560
nex15602y ago
Followed some thread somewhere a while back that was doing this ... Moving it up
Brody
Brody2y ago
interesting
nex1560
nex15602y ago
waaaiy waiiit
Brody
Brody2y ago
?
nex1560
nex15602y ago
nex1560
nex15602y ago
just delete this ? ah I believe the dj database thing was so I connect to the remote container from local dev so delete dj database url thing right ? or what's the idea ?
Brody
Brody2y ago
you very much want to keep this https://github.com/BADIUDragos/annedora-2-prod/blob/prod/backend/backend/settings.py#L125 this on the other hand, idk what this is for
nex1560
nex15602y ago
nex1560
nex15602y ago
this should do it ?
Brody
Brody2y ago
looks like it
nex1560
nex15602y ago
So like, are you like 1 person or is it multiple people just using that account for support ?
Brody
Brody2y ago
you think im more than 1 person?
nex1560
nex15602y ago
idk haha
Brody
Brody2y ago
im one person, but why
nex1560
nex15602y ago
7 days a week 24 hours idk hahaha
Brody
Brody2y ago
oh i though maybe because im forgetting things youve previously said
nex1560
nex15602y ago
nooo not at all you get paid for this right ?
Brody
Brody2y ago
no its for fun
nex1560
nex15602y ago
damn so you are a G
Brody
Brody2y ago
one could say that, yeah
nex1560
nex15602y ago
Brody
Brody2y ago
looks good test it with postman
nex1560
nex15602y ago
This is basically a small family business, my uncle is a beekeeper and we make honey and derivative products If you'd like I'd be more than happy to send you a jar or two PO box or whatever you'd like
Brody
Brody2y ago
thats very nice of you, but shipping costs wouldnt be worth it
nex1560
nex15602y ago
Are you in the US ?
Brody
Brody2y ago
canada
nex1560
nex15602y ago
We're also in canada, montreal
Brody
Brody2y ago
hows the air lol
nex1560
nex15602y ago
I'm sure I can cover the shipping It's not bad at all yesterday we had some smog
Brody
Brody2y ago
no no its okay, im just chilling
nex1560
nex15602y ago
Actually right now I am 2 hours north and you can smell a bit of smoke, but nothing too serious Just rained so not too bad
Brody
Brody2y ago
im southern ontario and its not bad at all, without rain, winds took it all to new york it seems lol
nex1560
nex15602y ago
Oh ok I have friends in Windsor
Brody
Brody2y ago
im not that much south
nex1560
nex15602y ago
lmao ok
Brody
Brody2y ago
Hamilton area to be vague
nex1560
nex15602y ago
Dude Shipping is gonna be like max 20$ for real Worse case I got a friend going to toronto next week
Brody
Brody2y ago
but what am i supposed to do with honey lol
nex1560
nex15602y ago
Many things You may replace your coffee sugar with a spoon You can put it on toast pankcakes
Brody
Brody2y ago
that stuff sounds like a lot of work
nex1560
nex15602y ago
xDDD Ok we have candles too and soaps
Brody
Brody2y ago
my mom likes candles
nex1560
nex15602y ago
Deal
Brody
Brody2y ago
okay well talk later, for now lets get your app online
nex1560
nex15602y ago
yessir
Brody
Brody2y ago
Brody
Brody2y ago
in your cloudflare, set it to full
nex1560
nex15602y ago
done
Brody
Brody2y ago
test your api with postman now
nex1560
nex15602y ago
https://api.annedora.ca/admin Shouldn't this display the django admin panel ?
Brody
Brody2y ago
ideally, but django is returning an internal server error what do the logs say?
nex1560
nex15602y ago
nex1560
nex15602y ago
just noticed
Brody
Brody2y ago
SECRET_KEY must not be empty
nex1560
nex15602y ago
ok 1 sec redeploying works
nex1560
nex15602y ago
Brody
Brody2y ago
awsome
nex1560
nex15602y ago
need to set debug to false tho 1 sec
Brody
Brody2y ago
yeah you can do that dynamically
nex1560
nex15602y ago
how ? oh yeah set it as variable too ? have different settings locally ?
Brody
Brody2y ago
nah i have better idea one sec
nex1560
nex15602y ago
Also, lowkey We're looking for people, just in case you're interested, I work at Rolls-Royce and we do fullstack, mostly django, might be a bit boring for you but hey just in case you know
Brody
Brody2y ago
unfortunately im not a python or django dev
nex1560
nex15602y ago
Oke
Brody
Brody2y ago
i appreciate the offer though 🙂
nex1560
nex15602y ago
Not an issue for my team tho We're interviewing fresh grads rn too lol so ... I appreciate your help sir
Brody
Brody2y ago
DEBUG = "RAILWAY_ENVIRONMENT" not in os.environ
DEBUG = "RAILWAY_ENVIRONMENT" not in os.environ
nex1560
nex15602y ago
?
nex1560
nex15602y ago
I have no idea ah
Brody
Brody2y ago
not in
nex1560
nex15602y ago
ah ok
Brody
Brody2y ago
told you im not a python dev lol
nex1560
nex15602y ago
smart i mean hey I never would have even thought of this so Dude you're a G stop ...
Brody
Brody2y ago
that way when it runs on railway RAILWAY_ENVIRONMENT will be in os.environ so debug will equate to False at least i think lol
nex1560
nex15602y ago
understood hey we're here to have fun
Brody
Brody2y ago
im learning too
nex1560
nex15602y ago
how old are you if I may ask you can also aikido deflect the question if you'd like
Brody
Brody2y ago
mom says 22 i forget these things
nex1560
nex15602y ago
lol
Brody
Brody2y ago
man at the casino asked how old i was upon entry and i went "uhhh" for a solid few seconds
nex1560
nex15602y ago
xDD works
Brody
Brody2y ago
all is good with backend? youve tested more than just /admin?
nex1560
nex15602y ago
api.annedora.ca not found instead of normal debut thing
Brody
Brody2y ago
huh oh yeah, you have no routes registered for the root, so thats normal
nex1560
nex15602y ago
yes one sec password not working for admin login or smth
Brody
Brody2y ago
are you sure the database on railway has all the required data?
nex1560
nex15602y ago
Yeah I had previously used it, when the website was deployed with the dockerfile had a staff account in django and everything
Brody
Brody2y ago
check the data with something like dbgate
nex1560
nex15602y ago
Hmm ok internet kinda slow where Im at rn gonna take a minute to download
Brody
Brody2y ago
what ya got
nex1560
nex15602y ago
also never used this before
Brody
Brody2y ago
speed wise
nex1560
nex15602y ago
like 50
Brody
Brody2y ago
bruh
nex1560
nex15602y ago
almost done downloading Hey it's northern quebec almost ahahhaha
Brody
Brody2y ago
50 is slow?
nex1560
nex15602y ago
I mean
Brody
Brody2y ago
i got 21
nex1560
nex15602y ago
I got gigabit in montreal damn. I'm sorry
Brody
Brody2y ago
lmao
nex1560
nex15602y ago
hmm yeah these don't look like normal django tables to me
Brody
Brody2y ago
did you ever have a local postgres database?
nex1560
nex15602y ago
nex1560
nex15602y ago
No that's why I'm a little confused
Brody
Brody2y ago
thats timescale stuff, comes standard with railways postgres database, you can ignore all those
nex1560
nex15602y ago
Yeah don't see the django specific tables
Brody
Brody2y ago
thats not ideal
nex1560
nex15602y ago
But in the service I do see them
Brody
Brody2y ago
show?
nex1560
nex15602y ago
\
nex1560
nex15602y ago
Like I even connected to the container from local And created a new superuser But it won't let me connect to django admin with it
Brody
Brody2y ago
with the railway cli?
nex1560
nex15602y ago
Local and on the deployment On deployment I get forbidden CSRF error
nex1560
nex15602y ago
nex1560
nex15602y ago
and locally
nex1560
nex15602y ago
Brody
Brody2y ago
this is not bad thing, its fixable this is normal, since you no longer have a .env file you dont have an .env file right?
nex1560
nex15602y ago
no .env no
Brody
Brody2y ago
okay good
nex1560
nex15602y ago
How is it related to .env tho ?
Brody
Brody2y ago
do you have the railway cli installed?
nex1560
nex15602y ago
negative
Brody
Brody2y ago
you see this because you dont have a .env file with your database credentials anymore, it cant check if the username exists since it cant connect to the database so go ahead and install the railway cli https://docs.railway.app/develop/cli#installation
nex1560
nex15602y ago
I guess this didn't do it then
Brody
Brody2y ago
ah you comment out code during local development thats not ideal lol
nex1560
nex15602y ago
I agree Just wanted to see what's up quick revert anyways
Brody
Brody2y ago
let me know when the cli is installed
nex1560
nex15602y ago
intalled also logged in
Brody
Brody2y ago
run railway link and railway service while in your backend folder
nex1560
nex15602y ago
Brody
Brody2y ago
show me railway status
nex1560
nex15602y ago
nex1560
nex15602y ago
Brody
Brody2y ago
railway service and choose your backend
nex1560
nex15602y ago
nex1560
nex15602y ago
done right ?
Brody
Brody2y ago
run railway variables and does that include the same stuff as in your railway service variables?
nex1560
nex15602y ago
Yup shows me everything
Brody
Brody2y ago
whats your regular start command to start django locally
nex1560
nex15602y ago
python manage.py runserver
Brody
Brody2y ago
okay so now you can do railway run python manage.py runserver so that your django app gets started locally but with all the railway variables available locally too wayyyy better than storeing database credentials in a plaintext .env file
nex1560
nex15602y ago
this is very cool thank you
Brody
Brody2y ago
check if login works locally
nex1560
nex15602y ago
I created another superuser via railway run railway up to deploy changes ?
nex1560
nex15602y ago
Brody
Brody2y ago
nope i hate that message
nex1560
nex15602y ago
oups, I did it ctrl c'ed
Brody
Brody2y ago
well could you login locally?
nex1560
nex15602y ago
still same issue very wierd incorrect pswd
Brody
Brody2y ago
btw you need to run anything that needs access to the database with railway run like the command to create a super user
nex1560
nex15602y ago
yeah that's what I did yeah I see the new user in the db on the service directly but I can't connect to it
Brody
Brody2y ago
hmmm well i dont know what to tell you, i cant see your database
nex1560
nex15602y ago
drop the db ? lol
Brody
Brody2y ago
lmfao no
nex1560
nex15602y ago
xD very odd ...
Brody
Brody2y ago
im acctually not sure what you meant, the term "drop the database" means to wipe the database
nex1560
nex15602y ago
yes I did mean that lol
Brody
Brody2y ago
oh lmao i mean its your data
nex1560
nex15602y ago
I will try to make another superuser maybe I made typos it's a fresh db, don't think theres a reason to drop it tho
Brody
Brody2y ago
dont you have some kind of api data on it??
nex1560
nex15602y ago
nada nothing
Brody
Brody2y ago
where is your data then lol
nex1560
nex15602y ago
What data
Brody
Brody2y ago
arent you building a store or something
nex1560
nex15602y ago
yeah
Brody
Brody2y ago
so product data
nex1560
nex15602y ago
Don't have any products added all the tables are empty Products may be added from front end
Brody
Brody2y ago
fancy
nex1560
nex15602y ago
upload pictures etc need to find a way to keep the images properly after this s3 bucket or something idk that's for later ....
Brody
Brody2y ago
yes since railway doesnt have persistent storage i recomend cloudflare r2, you use amazon's s3 sdks with it and the first 10gb is free
nex1560
nex15602y ago
Thank you I will look into that
Brody
Brody2y ago
or if its just images, cloudinary is great for media
nex1560
nex15602y ago
Really just images ... Product picture
Brody
Brody2y ago
then cloudinary
nex1560
nex15602y ago
front end logo, but I can just throw that directly in the reactapp and the ico
Brody
Brody2y ago
true
nex1560
nex15602y ago
it's mostly just the product pictures
Brody
Brody2y ago
product pics would go to cloudinary yeah either way, gotta figure out why you cant login as the superuser you said you can see the superuser in the database through dbgate?
nex1560
nex15602y ago
jsut made another one still not working I can't see the tables I see in the postgres service inside of dbgate at all ah
Brody
Brody2y ago
you wanna just dm the database url lol
nex1560
nex15602y ago
nvm it's inside railway
nex1560
nex15602y ago
nex1560
nex15602y ago
here
Brody
Brody2y ago
ah perfect
nex1560
nex15602y ago
yeah I see the same as in the postres sevice they're all there fkn wierd
Brody
Brody2y ago
run railway run python manage.py migrate && python manage.py runserver locally then try login
nex1560
nex15602y ago
nothing to apply tho I already applied I still ran it
Brody
Brody2y ago
try login
nex1560
nex15602y ago
yeah wrong username and password message so wierd
nex1560
nex15602y ago
I get a 200 status code too
Brody
Brody2y ago
well since im not a django dev, off to google you go lol
nex1560
nex15602y ago
yupp ...
Brody
Brody2y ago
any web console errors though?
nex1560
nex15602y ago
Brody
Brody2y ago
odd well let me know when you find out whats up, gotta get that backend running locally before we try on railway again
nex1560
nex15602y ago
found a thread on this issue 2 minutes
nex1560
nex15602y ago
nex1560
nex15602y ago
django_session table empty
Brody
Brody2y ago
how make not empty
nex1560
nex15602y ago
remove non standard settings I don't have any of these make sure db is synced ? meaning what I created superusers db is synced no ? try to authenticate, yeah good luck lol
Brody
Brody2y ago
isnt that what migrate does
nex1560
nex15602y ago
link is 404
Brody
Brody2y ago
oof
nex1560
nex15602y ago
yeah ok migrate does that exactly
Brody
Brody2y ago
wish i knew django so that i could help you out here more
nex1560
nex15602y ago
So like do you work also ? freelance or something ?
Brody
Brody2y ago
nope 🙂
nex1560
nex15602y ago
you learn full time ?
Brody
Brody2y ago
nope i fuck around full time
nex1560
nex15602y ago
i respect that xD
Brody
Brody2y ago
bank account would rather i didnt though lmao
nex1560
nex15602y ago
eh ... one of the consequences
Brody
Brody2y ago
true
nex1560
nex15602y ago
Do you plan on getting a dev role or something ?
Brody
Brody2y ago
not smart enough to dev
nex1560
nex15602y ago
No way dude
Brody
Brody2y ago
yeah fr, im not qualified for a dev role
nex1560
nex15602y ago
How
Brody
Brody2y ago
theres so much i dont know
nex1560
nex15602y ago
Bro ... That's like All of us You're underestimating yourself
Brody
Brody2y ago
i cant figure out why you cant login to your app, i am not underestimating myself
nex1560
nex15602y ago
HAHAHA bro I can't figure out either still browsing
Brody
Brody2y ago
by that logic we both arent qualified for a dev role
nex1560
nex15602y ago
haha
Brody
Brody2y ago
sorry you have to quit your fancy car job, i dont make the rules
nex1560
nex15602y ago
facts Found this thread on stackoverflow dude posted this issue in 2020 and replied in march 2023, I switched jobs, been doing c# for the past 3 years, can't remember how I fixed the issue back then rip lmao
Brody
Brody2y ago
omfg just like the memes
nex1560
nex15602y ago
Stack Overflow
Forbidden (403) CSRF verification failed. Request aborted. Reason g...
Help Reason given for failure: Origin checking failed - https://praktikum6.jhoncena.repl.co does not match any trusted origins. In general, this can occur when there is a genuine Cross Site Request
nex1560
nex15602y ago
found this if you understand something I added that line but nothing
Brody
Brody2y ago
thats for the issue when on railway, gotta get your app working locally first are there no console errors from django when the login fails?
nex1560
nex15602y ago
nope
Brody
Brody2y ago
odd
nex1560
nex15602y ago
literally just a successfull 200 post
Brody
Brody2y ago
what does the response of that request say tho
nex1560
nex15602y ago
1 sec I think we can just say fuck this Cause I have enough functionality in the frontend to overwrite my backend admin needs and will be able to login to staff from frontend
Brody
Brody2y ago
will you tho
nex1560
nex15602y ago
will look at it later hopefully
Brody
Brody2y ago
can you login staff from backend locally?
nex1560
nex15602y ago
negative
Brody
Brody2y ago
then it wont work from frontend lol
nex1560
nex15602y ago
I have had this in the past And it worked And then it somehow fixed itself don't ask I have no idea
Brody
Brody2y ago
well okay then, we can deploy the frontend tommorow, shouldnt take this much effort
nex1560
nex15602y ago
yup will continue to look at it for a bit tho all good thank you
Brody
Brody2y ago
since we are in the same timezone, its late lol
nex1560
nex15602y ago
yeeeeah no worries man really appreciate it once again have a good one see you later
Brody
Brody2y ago
no problem, always happy to help, cya
nex1560
nex15602y ago
still no solution for the admin thing
Brody
Brody2y ago
thats unfortunate
nex1560
nex15602y ago
indeed
Brody
Brody2y ago
do you still wanna deploy your frontend anyway?
nex1560
nex15602y ago
yeah
Brody
Brody2y ago
okay create a new service and give it a frontend name
nex1560
nex15602y ago
done
Brody
Brody2y ago
have you added your domain?
nex1560
nex15602y ago
yes
nex1560
nex15602y ago
Brody
Brody2y ago
set your root directory to /frontend?
nex1560
nex15602y ago
initializing
Brody
Brody2y ago
cool
nex1560
nex15602y ago
Will have to change all the routes tho actually gonna be https://api.annedora.ca/wtv right ?
Brody
Brody2y ago
if you used to call just /wtv then yes you are correct
nex1560
nex15602y ago
well, I guess brb
Brody
Brody2y ago
i mean did the build and deploy work?
nex1560
nex15602y ago
nex1560
nex15602y ago
negative
Brody
Brody2y ago
whats the reason? youre smart enough to know that isnt the actual error message
nex1560
nex15602y ago
treating warnings as errors because process.env.CI = true failed to compile
Brody
Brody2y ago
haha your build has warnings
nex1560
nex15602y ago
lmao
Brody
Brody2y ago
fix it later
nex1560
nex15602y ago
Will do lmao
Brody
Brody2y ago
for now, set CI = false in the railway service variables
nex1560
nex15602y ago
I got a couple of #12 35.21 Line 3:24: 'Row' is defined but never used no-unused-vars #12 35.21 Line 3:29: 'Col' is defined but never used no-unused-vars xDDD
Brody
Brody2y ago
very common, i see that all the time
nex1560
nex15602y ago
Will cleanup later just trying to push main features and deploy
Brody
Brody2y ago
gotcha
nex1560
nex15602y ago
Gonna do localization later aswell as other features For francophones
Brody
Brody2y ago
dont know what that is
nex1560
nex15602y ago
Like set language to french based on if they're in quebec and then have the en/fr thing at the top to switch well deployed all right but it's somehow got a wierd ass error, checking the code
Brody
Brody2y ago
ah i see
nex1560
nex15602y ago
will lyk when I fix that and the urls well well welll be my guest please and check out annedora.ca also login via frontend works
Brody
Brody2y ago
no image 😦
nex1560
nex15602y ago
haha yeah that was a test product Images is next indeed
Brody
Brody2y ago
very nice
nex1560
nex15602y ago
Actually no
Brody
Brody2y ago
not nice?
nex1560
nex15602y ago
emails is the next issue which was the first issue in the first place lmao yes very nice happy it's online
Brody
Brody2y ago
awsome
nex1560
nex15602y ago
nex1560
nex15602y ago
So you're saying these types of email sending should work right ?
Brody
Brody2y ago
i dont see why not also, you will setup an [email protected] email right? or something along those lines
nex1560
nex15602y ago
Yeah those are already setup just sending emails to myself for now
Brody
Brody2y ago
cool now i think is a good time to tell you
nex1560
nex15602y ago
you're breaking up with me ?
Brody
Brody2y ago
usually the team plan is required when hosting a commercial product on railway, but this is just a simple storefront for your parents business, so im confident in saying that the railway team wont have any problems with it as long as you are on the dev plan
nex1560
nex15602y ago
yeah of course will be Cool, thank you
Brody
Brody2y ago
looks like your github account will be verifiable without issue, so just upgrade to the dev plan sometime soon
nex1560
nex15602y ago
Yeah Just gonna fix all the issues first
Brody
Brody2y ago
makes sense
nex1560
nex15602y ago
hopefully sending emails works
Brody
Brody2y ago
remember you dont need to deploy every change, do as much testing as you can locally
nex1560
nex15602y ago
true I should setup a dev branch Railway will only pull from the prod branch correct ? So whenever I merge a PR should deploy
Brody
Brody2y ago
fun fact, i dont use github very much, so i am also no help there i have never deployed my own code from github
nex1560
nex15602y ago
Interesting
Brody
Brody2y ago
all testing is done locally, and i simply just write code that i know works on railway
nex1560
nex15602y ago
A master jedi who has only thought other how to use the force, but never used it himself ah ok makes sense What apps do you have on here ?
Brody
Brody2y ago
this is my most publicly used app https://utilities.up.railway.app/ bunch of demos or utilities for railway stuff
nex1560
nex15602y ago
You're making railway a bunch of money
Brody
Brody2y ago
how
nex1560
nex15602y ago
If you don't work for them as you say, they should definetely hire you lol I mean, by helping people use the service
Brody
Brody2y ago
ah i see
nex1560
nex15602y ago
You're a huge business catalyst
Brody
Brody2y ago
but the thing is, they dont need to hire me to get me to help the users, i help regardless, so why would they hire me for something im already doing
nex1560
nex15602y ago
Yeah I said should
Brody
Brody2y ago
true
nex1560
nex15602y ago
xDDD
nex1560
nex15602y ago
nex1560
nex15602y ago
This should work right ?
Brody
Brody2y ago
nope the start script is only for railway now, thats why my guide had you rename the original start script to dev
nex1560
nex15602y ago
truueee forgot about that You good with react/front end right ?
Brody
Brody2y ago
absolutely not
nex1560
nex15602y ago
I got the wierdest shit happening not even email related
nex1560
nex15602y ago
nex1560
nex15602y ago
This is on the deployment
nex1560
nex15602y ago
nex1560
nex15602y ago
This is local With railway cli
Brody
Brody2y ago
any browser console errors?
nex1560
nex15602y ago
I mean yes But only for the stripe part which is not what worries me The order summary block shows results from an API call which is successful according to reduc redux and I see the state values updated
Brody
Brody2y ago
ah the joys of deploying code that was only developed with running it locally in mind
nex1560
nex15602y ago
wait nvm
nex1560
nex15602y ago
nex1560
nex15602y ago
interesting
Brody
Brody2y ago
very
nex1560
nex15602y ago
I literally just redeployed a change where I moved the logo and the ico in public/images and this is fixed but the logo and ico aren't working
nex1560
nex15602y ago
interesting
Brody
Brody2y ago
frontend is hard eh, thats why i dont do frontend
nex1560
nex15602y ago
What do you do ?
Brody
Brody2y ago
backend, and when i do rarely do frontend its vanilla js, none of that react crap
nex1560
nex15602y ago
Backend with what ?
Brody
Brody2y ago
no offense, react is just confusing for me golang
nex1560
nex15602y ago
haha dude none taken dw I just learned react Cause I want to become a contractor or something cool haven't gotten into golang yet
Brody
Brody2y ago
yeah lots of jobs for react, time to learn nextjs next
nex1560
nex15602y ago
That's the plan yup After this I'll do like a portfolio app and use that as nextjs learning project React/Django is pretty popular Just gotta get a couple more years experience And obviously deploy it on Railway, duh
Brody
Brody2y ago
another fun fact, railway is not geared towards frontends
nex1560
nex15602y ago
In what way ? btw, what did you say to use for images again ?
Brody
Brody2y ago
its just designed to deploy backend api services
nex1560
nex15602y ago
I see I mean it works ...
Brody
Brody2y ago
netlify, vercel, github pages, cloudflare pages, etc are purpose built for frontends true cloudinary
nex1560
nex15602y ago
And from what I can tell it's super simple and efficient thank you gonna look at it right away You go to uni btw ?
Brody
Brody2y ago
nope
nex1560
nex15602y ago
Good Dude you're super smart
Brody
Brody2y ago
real (school not good)
nex1560
nex15602y ago
I respect it And what you're doing is super smart also You're in a very good place for learning
Brody
Brody2y ago
yep ive learned so much
nex1560
nex15602y ago
ngl you've got me thinking about quitting my job and stopping to waste my time there And doing the same thing or similar
Brody
Brody2y ago
bro you work for rolls royce
nex1560
nex15602y ago
The job ain't bad, I'll admit It's the people that I hate Maybe now that I'll work on a new project with react instead of jquery and shit it'll be better And with new hires coming in changing the vibe Dude you sure you don't want a refferal ?
Brody
Brody2y ago
im not a django dev lol
nex1560
nex15602y ago
Doesn't matter, we provide training As most jobs do However right now we're interviewing some seniors so idk how it would go
Brody
Brody2y ago
but i dont like python
nex1560
nex15602y ago
Ok, fair enough ahahha
Brody
Brody2y ago
its kinda slow by default, and has a much higher resource footprint compared to golang but thats just my take, everyone should use the language that fits them best
nex1560
nex15602y ago
Most people coming out of uni have less important knowledge than you're exposed to in a single month Yeah I mean, once a company kinda starts some projects with something they stick with it unless there's a separate need or something Businesses don't care as long as their money is coming in and results are being rolled out
Brody
Brody2y ago
so real
nex1560
nex15602y ago
@Brody Do you know if I can send images from one service to the other ?
Brody
Brody2y ago
if you code for that functionally in your own apps
nex1560
nex15602y ago
well I already had this functionality but I don't know how to see the images/if they're actually being there I tried running in debug locally with CLI but doesn't seem to be a good way Added backend to cloudinary
Brody
Brody2y ago
well for starters how did you do this before?
nex1560
nex15602y ago
trying to run it in debug somehow locally Files were saved in media folder from django now we split the service into two so should've technically still do it Uploaded from FE to BE via simple request
Brody
Brody2y ago
and what fails?
nex1560
nex15602y ago
Well The requests succeeds in production But the image wasn't there
Brody
Brody2y ago
but you want to be saving images to cloudinary
nex1560
nex15602y ago
exactly
Brody
Brody2y ago
so you shouldn't need to do a disk write, you can do an in memory buffer and upload straight to cloudinary
nex1560
nex15602y ago
Used this Does it look legit to you
Brody
Brody2y ago
idk kinda looks like AI generated garbage
nex1560
nex15602y ago
ChatGPT wasn't there when it was published tho xD
Brody
Brody2y ago
wdym we had AI in 2022 either way, it's a garbage article I'd personally implement the upload endpoint myself using the cloudinary sdk directly relying on too many random packages is never a good thing
nex1560
nex15602y ago
Still looking into the email thing also Do you know any other threads with similar issues ? Seen some but nobody ever answered them
Brody
Brody2y ago
what's wrong with sending emails
nex1560
nex15602y ago
They're not sending Log says here let me redeploy cause I changed smth 1 sec
Brody
Brody2y ago
haha okay
nex1560
nex15602y ago
nex1560
nex15602y ago
File "/opt/venv/lib/python3.10/site-packages/django/utils/log.py", line 128, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "/opt/venv/lib/python3.10/site-packages/django/utils/log.py", line 132, in send_mail
subject, message, *args, connection=self.connection(), **kwargs
File "/opt/venv/lib/python3.10/site-packages/django/utils/log.py", line 136, in connection
return get_connection(backend=self.email_backend, fail_silently=True)
File "/opt/venv/lib/python3.10/site-packages/django/utils/log.py", line 128, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "/opt/venv/lib/python3.10/site-packages/django/utils/log.py", line 132, in send_mail
subject, message, *args, connection=self.connection(), **kwargs
File "/opt/venv/lib/python3.10/site-packages/django/utils/log.py", line 136, in connection
return get_connection(backend=self.email_backend, fail_silently=True)
Small mention of email trace here And then throws a
ModuleNotFoundError: No module named "'django"
ModuleNotFoundError: No module named "'django"
.... Not very informative tbh I've seen this log on multiple threads No conclusions Wait I don't need quotes for string values in railway variables right ?
Brody
Brody2y ago
I'm no django dev, but that looks like something you should ask Google about
nex1560
nex15602y ago
oH WELL Just fixed it Thanks for listening to my BS, it actually allowed me to think better at 1am let's see if I get the email now yup got it variable had quotes
Brody
Brody2y ago
easy fix
nex1560
nex15602y ago
Oh well Only cloudinary left now I'll leave that one for tomorrow Good night G
Brody
Brody2y ago
if possible try to use the least amount of dependencies as possible, less dependencies = faster build time
nex1560
nex15602y ago
Yeah, makes sense Well Used the django package for cloudinary Amazingly easy to implement once I found the correct documentation Didn't even have to change something in the FE
Brody
Brody2y ago
Whats FE?
nex1560
nex15602y ago
front end
Brody
Brody2y ago
fancy acronyms
nex1560
nex15602y ago
lol @Brody enabled stripe live and activated developer plan Processed first payment too
Brody
Brody2y ago
that's awesome!
Want results from more Discord servers?
Add your server