GithubHelp home page GithubHelp logo

sortalongo / sortalonco Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 2.42 MB

Personal website, written in Haskell on Yesod, deployed with Google Cloud Run.

Emacs Lisp 0.76% Haskell 93.47% CSS 1.13% JavaScript 4.64%

sortalonco's Introduction

sortalon.co

This is the code that runs my personal site. It uses the Yesod framework using the default site template, builds with Stack, and deploys a Docker container on Google Cloud Run.

Development

Stack is the build tool that automates most of the building commands you need:

$ stack build
$ stack test
$ stack ghci
$ stack exec -- $COMMAND

These are all quite useful, and do what you'd expect. The latter two perform their respective tasks using the dependencies declared in the cabal file. The tool is also well-documented:

$ stack --help

Yesod has a convenient development mode that automatically recompiles the code when you make changes to it. I haven't yet been able to get this working in the Dockerized container, so you have to tell Stack to run it directly on your machine:

$ stack --no-docker exec -- yesod devel

Note: This will likely require rebuilding all of the app's dependencies, since the Docker container seems to keep a separate cache of built artifacts.

Deployment

I did all my work from OS X, so I assume that environment.

Ensure you have Docker set up:

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v1.10.3
$ docker-machine start default # if the VM isn't running.
$ eval $(docker-machine env default) # set up ENV for docker CLI
$ docker ps # just check things are set up right
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS               NAMES

Build a Docker image:

$ stack image container

Run the image:

$ docker run sortalongo/sortalonco-webserver

Make sure it works:

$ docker exec `docker ps --format="{{.ID}}" -l` curl http://localhost:3000/

To keep the image for posterity:

$ docker tag sortalongo/sortalonco-webserver sortalongo/sortalonco-webserver:VERSION

Once that's done, we need to get the image to Google Cloud. I'll omit details specific to my setup. Setup is pretty straightforward. Just follow the standard flow for a Google Container Engine cluster and Google Container Repository. By the end, you'll have the gcloud and kubectl tools set up to talk to your G.E accounts & projects.

  1. Push the image to GCR (make sure you ran gcloud auth configure-docker):
$ docker tag sortalongo/sortalonco-webserver us.gcr.io/PROJECT/webserver:VERSION
$ docker push us.gcr.io/PROJECT/webserver:VERSION
  1. Create a service in the Cloud Run UI using the pushed image.

(If you're wondering why this README is so basic, it's because it used to detail deployment using Kubernetes. Cloud Run is way simpler, but the doc was already written, so I just trimmed it down)

sortalonco's People

Stargazers

Jeremy Bornstein avatar Rune K. Svendsen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.