Run go install
from backend/
From the project root directory:
cd frontend
npm install
Within the frontend/
folder, run
npm run build
This will create or update index.html
and bundle/bundle.js
inside dist
(The dist
folder will be created if it doesn't exist). For more information on npm run build
, take a look at package.json
and webpack.
The backend will use frontend/dist/index.html
as a html template, which it populates using data from the database and serves to the browser.
Within the frontend/
folder, run
npm start
This will starts the frontend in development mode and begin listening on port (8080
by default). Visit localhost:8080
if it is not opened in browser yet. :x
Note that this is limited in the sense that the frontend doesn't pull data from the database. Only the backend is able to pull data, populate the template, and serves to the browser. Therefore, the page you will see on localhost:8080
isn't populated with data. However, this is a convenient way to see the effect of stylesheets, and some frontend scripts.
To run a local database, make sure you have redis
installed. Start the server by running redis-server
. This will start the database on port 6379
by default.
You need to run two different database for development and testing. Specify the database url for each database in backend/config.go
.
From the backend/
folder, run
go run server.go
to start the server. Make sure that the database config is correct in the config.go
file.
From the backend/
folder, run go test
to start the tests.
- Make sure you have run
npm run build
to reflect your latest edit on frontend - Use Copilot to deploy!
Under project root directory, run:
touch db.Dockerfile
echo "FROM redis\nEXPOSE 6379" >> db.Dockerfile
This will expose the port 6379
for incoming traffic. You can use a different port but make sure to change the deployment configuration in backend/config.go
accordingly.
While using Copilot:
- Use
db.Dockerfile
to deploy the database - Be sure to select "Backend App" for app type. For more information, visit here. You can use environment variables to set up the
dbURL
inbackend/config.go
, as described here.
Similarly, deploy the backend using Copilot, and select "Load Balanced Web App" for app type. For more information, visit here.