Skip to content

Instantly share code, notes, and snippets.

@juniorz
Last active December 28, 2015 16:19
Show Gist options
  • Save juniorz/7528566 to your computer and use it in GitHub Desktop.
Save juniorz/7528566 to your computer and use it in GitHub Desktop.
ThoughtWorks Go Server
# -------------------------------------------------------------------
# $ docker build -t juniorz/go-server git://gist.github.com/7528566.git
# -------------------------------------------------------------------
# 1. $ docker run -d -p 8080:8153 juniorz/go-server
# 2. Go to http://localhost:8080/go/
# -------------------------------------------------------------------
FROM phusion/baseimage:0.9.1
MAINTAINER Reinaldo Junior <juniorz@gmail.com>
RUN apt-get update && apt-get upgrade -y
# Remove authentication rights for insecure_key.
RUN echo /bin/sh -c \"rm -f /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys\" > /sbin/remove_authorized_keys &&\
chmod 0700 /sbin/remove_authorized_keys
# To remove the key, run:
# curl https://raw.github.com/phusion/baseimage-docker/master/image/insecure_key |\
# ssh -i /dev/stdin root@$(docker inspect $CID | grep IPAddress | cut -d '"' -f 4) /sbin/remove_authorized_keys
# Set correct environment variables.
ENV HOME /root
# Installs
RUN curl -# http://download01.thoughtworks.com/go/13.3.1/ga/go-server-13.3.1-18130.deb -o /tmp/go.deb
RUN export LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive RUNLEVEL=0 &&\
apt-get install -y java7-runtime-headless unzip &&\
dpkg -i /tmp/go.deb
# Disables init
RUN /etc/init.d/go-server stop &&\
update-rc.d -f go-server remove &&\
rm /etc/init.d/go-server
# Adds go-server service
RUN mkdir /etc/service/go-server
ADD go-server.sh /etc/service/go-server/run
RUN chmod 0755 /etc/service/go-server/run
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
EXPOSE 8153
EXPOSE 8154
#!/bin/sh
set -xeu
# From /etc/init.d/go-server
[ -r /etc/default/go-server ] && . /etc/default/go-server
[ -d /var/run/go-server ] || (mkdir /var/run/go-server && chown -R go:go /var/run/go-server)
export MANUAL_SETTING="Y"
export DAEMON="N"
#export GO_SERVER_PORT=8080
#export GO_SERVER_SSL_PORT=8081
exec chpst -u go /usr/share/go-server/server.sh >> /var/log/go-server/go-server.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment