Prerequisites:
- Docker (installed and running in the background)
- Run the services:
docker-compose -f docker-compose.yml down && docker-compose -f docker-compose.yml up --build --force-recreate
Now your API (without the React UI) should be available at http://localhost:1111/api
. You can for example try running curl http://localhost:1111/api/events
in the terminal.
Prerequisites:
- Go (Golang) installed (i.e.
brew install golang
) - Docker (installed and running in the background)
- The Campsite repo cloned into
~/go/src/
- Start the database:
./scripts/dev dbstart
(you might need to stop it if you started it previously:./scripts/dev dbstop
). - Run all the services similarly, for
api
it is:cd services/api
and thengo run main.go
Now your API (without the React UI) should be available at http://localhost:1111/api
. You can for example try running curl http://localhost:1111/api/events
in the terminal.
Please keep in mind it's just the API. If you wanna run the interface too, please visit the campsite-ui
repo available at https://github.com/dnielsen/campsite-ui
.
- Go to
https://aws.amazon.com/console
and sign in. - Once signed in, click
Services
in the upper left corner and selectEC2
. - Click
Launch Instance
. - Select
Ubuntu Server 20.04 LTS (HVM), SSD Volume Type
- Select
t2.micro
(free tier eligible). - Click
Next: Configure Instance Details
. - Click
Next: Add Storage
. - Click
Next: Add Tags
. - Click
Next: Configure Security Group
- Click
Add Rule
and set theType
toAll traffic
andSource
toAnywhere
. - Click
Review and Launch
. - Click
Launch
. - Select
Create a new key
, give it a name, clickDownload Key Pair
, and thenLaunch Instance
. - Click on the name of your instance (inside the green box, like
i-0b39c78…
). - Go to the directory where you've saved the
.pem
file (key pair), and runchmod 400 yourKeyName.pem
. - Connect to the EC2:
ssh -i yourKeyName.pem ubuntu@YOUR.EC2.IP.ADDRESS
- Update Linux and install Docker, Docker Compose, and Nginx on your EC2:
sudo apt-get update
sudo apt-get -y install docker
sudo apt-get -y install nginx
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo snap install docker
sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
- Download your repos.
git clone https://github.com/dnielsen/campsite
mv campsite api
git clone https://github.com/dnielsen/campsite-ui
mv campsite-ui ui
git clone https://github.com/hypertrace/hypertrace
- Add nginx config
cd
sudo mv -f api/nginx/sites-available/default /etc/nginx/sites-available/default
- Start Docker:
sudo service docker start
. - Start Nginx:
sudo service nginx start
. - Build the ui
cd
cd ui
sudo apt-get install -y npm
sudo npm install
sudo npm run build
- Run the api:
cd
cd api
sudo docker-compose up -d
- (optional) Run Hypertrace
cd
cd hypertrace/docker
sudo docker-compose -f docker-compose.yml up
Your app has just been deployed. When you go to your EC2 Dashboard there's Public IPv4 address
and Public IPv4 DNS
. You can use either of them to connect to your API.
If you have run Hypertrace, it's available at YOUR.PUBLIC.IP:2020
.
- Create the RDS
- Replace the database config in
docker.env
with the RDS configuration.