📰 Good News app. Backend in Golang. Docker Compose & Traefik v2.0 on Digital Ocean.

Let’s show our project to the world!

  1. 📰 Good News app. Backend in Golang behind Traefik reverse proxy with https available.
  2. [in progress] 📰 Good News app. Flutter for rapid mobile applications development.
  3. [in progress] 📰 Good News app. Hummingbird as a promising replacement for frontend frameworks.
  1. Prerequisites & Idea, project and database structure and API endpoints.
  2. Project creation, go modules & GIN (beautiful framework) integration.
  3. Colly usage.
  4. MongoDB setup using official Golang driver.
  5. Running all together locally with Docker and Docker Compose & Traefik v2.0 configuration.
  6. Publishing to Digital Ocean, Let’s Encrypt and DNS Challenge configuration.

Registering a domain on Domains.Google


Digital Ocean

  • Choose image: Go to Marketplace tab and choose Docker image from the list. It means that Docker will be preinstalled on a server.
  • Choose a plan: For educational purposes, let’s pick the cheapest option that costs $5 a month.
  • Add block storage: None.
  • Choose a datacenter region: Well it depends where you live, I usually pick one in Europe.
  • Select additional options: None.
  • Authentication: Here pick a SHH Key that you have added earlier.
  • Other options are up to you.

Deploying backend to DO droplet

> ssh root@droplet_IP
> ls -l
acme.json - should be here for generating certificates for https
appdata/ - is used by MongoDB, no need to create it by our owngood-news/
api/ - where our project is going to be located
docker-compose.yml - Docker Compose file where all information for deploying is placed
> mkdir acme && touch acme/acme.json
> chmod 600 acme/acme.json
> mkdir good-news
> cd good-news
> git clone https://github.com/kanzitelli/good-news-backend api/
> nano .env
> nano docker-compose.yml

Let’s run it!

> docker-compose build && docker-compose up -d
# Opening shell of mongo db running within our docker container
> docker exec -it mongo mongo -u "GGCTeamBatr" -p "MySuperSecretPassword" --authenticationDatabase admin
# Changing to (creating) a needed db
> use good_news_db
# Creating a super user
> db.createUser({user: 'suuuper_user', pwd: 'soop3r_U$eR_PSWD', roles:[{role:'dbOwner', db:'good_news_db'}]})
# Inserting test data to test collection
> db.test_collection.insert({ test: "test" })
# Displaying all collections of our previously created db in order to make sure that our test collection was successfully created
> show collections
# Saying goodbye to mongo shell
> exit
> docker-compose build && docker-compose up -d



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store