Server for flutterbeer
Running (soon) at https://innovation-242008.appspot.com/
- Install go
- Install postgresql
Check out the code
Suggested IDE: vscode
Create database
CREATE USER gobeeruser WITH PASSWORD 'thisisthepassword';
CREATE DATABASE beerdb OWNER gobeeruser;
Create table(s)
CREATE TABLE users (id BIGSERIAL PRIMARY KEY, username TEXT);
CREATE TABLE tastings (id BIGSERIAL PRIMARY KEY, name TEXT);
CREATE TABLE beers (id BIGSERIAL PRIMARY KEY, name TEXT, tastingID int);
CREATE TABLE coronabeers (id BIGSERIAL PRIMARY KEY, name TEXT, drinker TEXT, points INTEGER, created_at TIMESTAMP NOT NULL DEFAULT NOW());
Install dependencies
go get github.com/gorilla/mux
go get github.com/lib/pq
go get github.com/google/uuid
> go build
> ./gobeer
- Stop service
sudo service gobeer stop
- Copy
./gobeer
to/build/beer/gobeer
- Start service
sudo service gobeer start
- Setup database
docker run -p 5454:5432 --name gobeer -e POSTGRES_PASSWORD=secret -dt postgres
- Create systemd service
[Unit]
Description=gobeer
After=docker.service
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/build/beer/gobeer
[Install]
WantedBy=multi-user.target
- Create nginx configuration
server {
listen 80;
server_name beer.abilia-gbg.se;
root /build/beer;
error_log /build/error.beer.log;
access_log /build/access.beer.log;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
- Use cert for beer.abilia-gbg.se
Google App Engine at Abilia innovation project
- Connect GO Google App Engine with GloudSQL
- Setup proxy for development