Coder Social home page Coder Social logo

adilnaimi.com's Introduction

Title Description Date Categories
My personal blog setup
Deploying blog using CoreOS Docker and hugo.
04-02-2015
coreos
docker
hugo

Docker data only container

At first we need data container with templates and content for blog generation. I used next Dockerfile:

FROM debian:jessie

RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates git-core
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN git clone http://github.com/adilroot/adilnaimi.com.git /src
VOLUME ["/src/blog"]
WORKDIR /src
ENTRYPOINT ["git"]
CMD ["pull"]

There is no magic here: just clone repo to /src (it will be used below), and update it on container start.

Build image:

docker build -t blog/content .

Create data container:

docker run --name blog_content blog/content

To update content and templates from github we need just:

docker start blog_content

Hugo

Hugo -- very fast static site generator, written in Go.

Idea is to run hugo in docker container so it reads contents from one directory and writes generated blog to another.

Hugo dockerfile:

FROM crosbymichael/golang

#FROM golang:1.3-onbuild

RUN apt-get update && apt-get install --no-install-recommends -y bzr

RUN go get github.com/spf13/hugo

VOLUME ["/var/www/blog"]

ENTRYPOINT ["hugo"]
CMD ["-w", "-s", "/src/blog", "-d", "/var/www/blog"]

So, here we go get hugo and use /src/blog (remember this from content container?) as source directory for it and /var/www/blog as destination.

Now build image and run container with hugo:

docker build -t blog/hugo .
docker run --name blog --volumes-from blog_content blog/hugo

Here the trick with --volumes-from -- we used /src/blog from blog_content container, and yeah, we're going to use /var/www/blog from blog container.

Nginx

So, now we have container with templates and content blog_content, content with ready to use blog blog, it's time to show this blog to the world.

I write simple config for nginx:

server {
    listen 80;
    server_name adilnaimi.com;
    location / {
        root /var/www/blog;
    }
}

Put it to sites-enabled directory, which used in this pretty dockerfile:

FROM dockerfile/nginx

ADD sites-enabled /etc/nginx/sites-enabled/default

Build image and run container with nginx:

docker build -t blog/nginx .
docker run -p 80:80 -d --name=nginx --volumes-from=blog blog/nginx

That's it, now blog is running on adilnaimi.com and you can read it :) I can update it just with

docker start blog_content

adilnaimi.com's People

Contributors

adilnaimi avatar elhachimi avatar

Watchers

James Cloos avatar  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.