{ Josh Rendek }

<3 Go & Kubernetes

We’ll go over everything needed to get a small development environment up and running using code-server, buffalo and postgres for a remote dev environment.

First lets install Go and Buffalo with gofish:

1apt-update
2curl -fsSL https://raw.githubusercontent.com/fishworks/gofish/master/scripts/install.sh | bash
3gofish init
4gofish install go 
5gofish install buffalo
6buffalo version # should say 0.16.12 or whatever latest is

Install docker

curl -fsSL get.docker.com | bash

Install NodeJS & Yarn:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

Install code-server

curl -fsSL https://code-server.dev/install.sh | sh

Add your user:

sudo usermod -aG docker YOURUSER
# you made need to reboot after this step to get your user to talk to the docker daemon properly

Start code-server, as your regular user (ie: not sudo):

systemctl --user enable --now code-server

Edit your config only do this if its on a private, trusted network, don’t do this on an internet exposed server

.config/code-server/config.yaml:

1bind-addr: 0.0.0.0:8080
2auth: none
3password: xxxx
4cert: false

Restart the server:

1systemctl --user restart code-server

And finally let’s setup postgres:

1# for the server, this is quickest/easiest
2docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 --restart=always -d postgres
3# for client
4sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
5wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
6sudo apt-get update
7sudo apt-get install postgresql-client-12

You can now psql to your app from the terminal:

postgres://postgres:[email protected]:5432/demo_test?sslmode=disable

Let’s create our demo buffalo app:

1buffalo new demo
2cd demo

Edit your database.yml to look like this for development:

1---
2development:
3  url: {{envOr "DEV_DATABASE_URL" "postgres://postgres:[email protected]:5432/demo_test?sslmode=disable"}}

Then you can create and migrate your database:

1buffalo db create && buffalo db migrate

Now just run buffalo dev in your VS Code terminal and you can browse your app and start working on it.

If you want other things like the clipboard to work properly, I’d suggest setting up a proxy with auth and a real SSL certificate, for example using Traefik or Caddy.

comments powered by Disqus