In order to deploy mobile app to app stores, we need to use remote server (AWS, etc.) out of local environment one day. The problem was budjet. Of course, AWS offers amazingly easy service with Free Tier event for us to save money. However, considering my budjet plan, reducing constant cost was my prior strategy to keep maintaining this development routin without financial pressure.
While I was looking for alternative server, vultr was one of the best option for my condition. $5 per month, supplying 25 GB SSD and 1TB of Bandwidth usage. It seems the appropriate plan for development and early service provision under 1,000 users a day.
I did not use Docker this time yet, but instead used ssh to write codes remotely in VSCode. This setting does not require additional environment settings, but only connect the remote vultr server to my laptop with ssh.
The process of applying ssh is very popular on google search. If needed, please refer to easy instructions on Google or Youtube. All you need is looking around Vultr console, and retrieve necessary information such as ip address, keys, etc.
When you run the Django remote server on VSCode, there could be no server connection(404 error), even though you surely opened the virtualenv ($source env/Scripts/activate). When I tried to access the server from the mobile app, there was 404 error with the accurate ip address.
For this situation, you can try changing the ip address when running the remote server at the ssh connected VSCode command line.
$ python3 manage.py runserver 0.0.0.0:8000
Make sure if the port number is correct at the same time. Even if you are accessing the Django server with certain given ip address, your command to run the server is still local state in the remote virtual machine. Therefore, you will need to run the server as local address, and the default address is "localhost". We need to specifically set the address as 0.0.0.0 here.
At first, I tried to use local database(Postgresql) for mobile app development. However, connection with the remote django backend server and local db had complex setting difficulties. Even remote db will be necessary for the app deployment in the future anyways, so I used AWS rds for the remote database.
After registering AWS rds service, all we need to do is connecting db to the remote server (vultr).
project_name > settings.py
DATABASES = {
'default' : {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': APP NAME,
'USER': USERNAME,
'PASSWORD': PASSWORD,
'HOST': AWS RDS HOST ADDRESS,
'PORT': PORT NUMBER,
}
}
If you finished all the remote server and db settings, now we can work on writing codes alone!