DEV Community

Cover image for Installing Forem/Dev using Docker on Ubuntu
Akhil Naidu
Akhil Naidu

Posted on

Installing Forem/Dev using Docker on Ubuntu

Setting up Forem using Docker is one of the easiest ways to have Development Instance ๐Ÿ˜‡. If you already have Docker and Docker-Compose, you can install a development instance with a single command, but you guys, you don't deserve the fun ๐Ÿ˜ => You can check out the last section of this post and find the Golden Command


For the rest, let us do it but with fun ๐Ÿฅณ๐Ÿฅณ. Do you remember this song? One Kiss? ๐Ÿ‘ถ Which made Dua Lipa, the Dua Lipa?

One command is all it takes
fallin' love with Forem
Possibilities
I look Like all you need

One Kiss Lyrics

Fortunately, if you never installed Docker or Docker-Compose, don't worry ๐Ÿ˜ต, I'm here for you. Open Youtube in the new tab and play this "One Kiss ๐Ÿ’‹ by Dua Lipa" in the background and copy-paste my commands.


Installing Docker using Repository


All the commands are from the official documentation of Docker itself, so don't worry, just copy-paste. In case if you don't believe me ๐Ÿค”, click here, this will redirect you to the official documentation.

  • Updating and Installing some necessaries
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
Enter fullscreen mode Exit fullscreen mode
  • Adding Dockerโ€™s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode
  • Setting up the stable repository
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
Enter fullscreen mode Exit fullscreen mode
  • Updating and Installing Docker Engine
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
sudo apt-get install docker-ce docker-ce-cli containerd.io
Enter fullscreen mode Exit fullscreen mode
  • Testing the Docker Installation
sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

With this our Docker installation was done ๐Ÿ˜, now let's turn up towards the Docker-Compose Installation ๐Ÿ’ช.

In case, you are facing any errors!โ˜ ๏ธ Click Here, choose your OS and follow the official instructions ๐Ÿ’ฉ.


Installing Docker Compose


As I mentioned earlier, I am following the official documentation, so you can copy and paste. In case, if you want to follow them by yourself ๐Ÿ˜’๐Ÿ˜ค, click here

  • Downloading the current stable Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode
  • Giving executable permissions to the binary
sudo chmod +x /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode
  • Verifying the Installation
docker-compose --version
Enter fullscreen mode Exit fullscreen mode

For some unknown reason, if you end up with an error๐Ÿง try repeating the docker-compose installation only. If the error persisted, I would suggest you reinstall your OS ๐Ÿค’. You should not get an error๐Ÿ˜ค.


Time to change the Beat


Enough of One Kiss. Time for some awesome beats, check this out Strobe by Deabmau5 => Youtube link to Strobe

Now we have Docker and Docker Compose installed in our local machine, but there is one more thing left for us to do ๐Ÿ˜ณ. We forget to fork and download the Forem code into our local machine from the GitHub ๐Ÿคฏ.

I knew the response of many of you would be ๐Ÿคฌ, but bare with me ๐Ÿ‘ป.


Forking and Downloading the Forem code


Don't make me repeat it again ๐Ÿ˜ , play the Strobe by Deadmau5 in the background ๐Ÿค—. I knew you can't make a coffee whenever you have to wait for some time, here, the Docker can consume enough time to bore you up.

  • Fork the repository from the Github
Better do it by using Github website, don't copy and paste this -_-
Enter fullscreen mode Exit fullscreen mode

Link to the repository to fork: click here

  • Downloading the repository to you local machine
git clone https://github.com/<your-username>/forem.git
Enter fullscreen mode Exit fullscreen mode

Dude, please change the your-username to your own Github username, or else you can ๐Ÿคฎ on your experience ๐Ÿฅบ.

  • Enter into the downloaded Forem folder
cd forem
Enter fullscreen mode Exit fullscreen mode

The awaited Golden Command


๐Ÿฅต๐Ÿฅต๐Ÿฅต You did nothing, but yeah, I assume you are horrified by the way I demonstrate this ๐Ÿฅถ

  • Running Forem with Docker Via Docker-Compose
bin/container-setup
Enter fullscreen mode Exit fullscreen mode

This command will do its job, you just keep an eye on the terminal by listening to strobe ๐Ÿคญ๐Ÿคญ. You will really appreciate the work done by the team Forem, they really made it easy for us (non-developers), but sure you can call yourself a DEV after this.


Any improvements ๐Ÿ‘จโ€๐Ÿ”ฌ, suggestions ๐Ÿคฆโ€โ™‚๏ธ, and issues โ˜ ๏ธ are welcomed in the comment section. This is not formal documentation for me to shy out, load them out, and let us change it according to our needs.

With this, we have our own Development Instance. I will catch you in the next post ๐Ÿ‘จโ€๐Ÿ’ป ๐Ÿ‘ฉโ€๐Ÿ’ป (Devs), possibly with something similar to this but in a different environment.

Top comments (19)

 
akhilnaidu profile image
Akhil Naidu

In Digital Ocean we usually do not deploy like the case in Heroku.

In a vague sense, in Digital Ocean

  1. You buy VPS
  2. Install Forem, exactly like you do in your own system

But the main difference from your PC installation is that you will also change the app's environment variable to Production in the Digital Ocean.

In your personal PC, it is most; likely a development instance and by default uses production variables until you configure them to production.

Usually in Heroku, by default it is nodejs and many other variables are in a Production environment. Also, this is one of the main reason that you are supposed to configure all the environment variables in Heroku for a successful build and release.

Collapse
 
akhilnaidu profile image
Akhil Naidu

The command bin/container-setup is supposed to execute two steps; so try those two commands manually and let me know the status.

The script bin/container-setup executes these two steps in order.

  1. docker-compose build
  2. docker-compose up
 
akhilnaidu profile image
Akhil Naidu • Edited

Ok, I found one of my old text files which have a list of commands to Install Forem in Linux manually. So with less commentary, I am posting another article out of those.

Check out the next article in line or click here

 
akhilnaidu profile image
Akhil Naidu

By looking at the screenshot, I realised that you are using WSL. So I would like to suggest you to check your WSL version and if it is not WSL2, do change it to WSL2.

Secondly, while using docker it takes time for the initial setup, even if it is 8GB ram VM or HYPER-V, it may take up to 30-40 minutes. "Optimisation Issues:"

Collapse
 
sohahm profile image
Sohail Ahmed

Can I use this method to run a production instance or would you suggest another way?

Collapse
 
akhilnaidu profile image
Akhil Naidu

It is always better to have 2 different instances one in local (development) and the other to the public through the production (in Heroku or VPS)

Also, remember, unlike the development forem instance to have a working production instance you have to configure all most all the environment variable in the .env file.

Collapse
 
sohahm profile image
Sohail Ahmed

I would like to deploy it in production and I understand that I need to copy .env_sample as .env and add values but what about docker-compose.yml? It has RAILS_ENV, DATABASE_URL, and many things set as development. Do I have to modify it as well?

Please advise. Thank you.

Thread Thread
 
akhilnaidu profile image
Akhil Naidu

No need to modify system-oriented variables, by default in a system like Heroku the environmental variables of rails are configured as production. All you have to do is configure .env file.

Also just having a .env is not sufficient, you need to configure everything in it. Take for example the Cloudinary, Honey badger, Fastly, Pusher, Honeycomb, AWS.. All of them have to be configured.

Collapse
 
sohahm profile image
Sohail Ahmed • Edited

Yes, thank you. I will install and get back to you if there is anymore questions.

By the way, I used apt install docker-compose to install Docker Compose.

Thread Thread
 
akhilnaidu profile image
Akhil Naidu

Usually installing in such a way is not a problem, but downloading source code and installing it manually never, usually, results in an error.

Also, I would like to know if you have a successful forem production instance. If possible just ping me here, if you have one.

Collapse
 
obaviet profile image
obaviet

Can you guide the installation for production?

Collapse
 
akhilnaidu profile image
Akhil Naidu

I'm working on a individual SaaS for this purpose, ping me forem.dev

 
akhilnaidu profile image
Akhil Naidu

You can follow this guide, and it is working; I confirmed it in my Droplet.

There are some aftermath modifications for full functionality, in a day I might add those.

Thread Thread
 
sidcraftscode profile image
sid

Hi, it doesn't seem to work in my droplet

Thread Thread
 
akhilnaidu profile image
Akhil Naidu

Can you elaborate on the error?

Thread Thread
 
sidcraftscode profile image
sid

It says connection refused. I detailed this issue on forem.dev

Collapse
 
yanivnoema profile image
Yaniv Noema

Thanks for sharing ๐Ÿ‘

 
akhilnaidu profile image
Akhil Naidu

Deploying in Heroku is a bit different and even Forem itself is shifting from it, I think so.
Article 03, which I uploaded just now, can be used in Digital Ocean too.

Collapse
 
ellos profile image
Ello