Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Improved Dockerfile.gocd-agent #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions Dockerfile.gocd-agent
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# Build using: docker build -f Dockerfile.gocd-agent -t gocd-agent .
FROM phusion/baseimage:0.9.16
FROM java:openjdk-7-jre
MAINTAINER Aravind SV <[email protected]>

RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh
RUN apt-get update && apt-get install -y -q unzip openjdk-7-jre-headless git
RUN mkdir -p /var/run/go-agent

RUN mkdir /etc/service/go-agent
ADD gocd-agent/go-agent-start.sh /etc/service/go-agent/run
WORKDIR /tmp

ADD http://download.go.cd/gocd-deb/go-agent-15.2.0-2248.deb /tmp/go-agent.deb
RUN curl -L http://download.go.cd/gocd-deb/go-agent-15.2.0-2248.deb > /tmp/go-agent.deb && \
dpkg -i /tmp/go-agent.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /tmp
RUN dpkg -i /tmp/go-agent.deb
RUN sed -i 's/DAEMON=Y/DAEMON=N/' /etc/default/go-agent
RUN mkdir -p /var/lib/go-agent/config
RUN rm -f /etc/default/go-agent

ENV GO_SERVER=go-server
ENV GO_SERVER_PORT=8153
ENV AGENT_WORK_DIR=/var/lib/go-agent
ENV AGENT_KEY=123456789abcdef
ENV DAEMON=N
ENV VNC=N

ENV JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD gocd-agent/go-agent-start.sh /usr/local/bin/go-agent

CMD ["/sbin/my_init"]
CMD ["/usr/local/bin/go-agent"]
8 changes: 2 additions & 6 deletions gocd-agent/go-agent-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ COLOR_START=""
COLOR_END=""

echo -e "${COLOR_START}Starting Go Agent to connect to server $GO_SERVER ...${COLOR_END}"
sed -i -e 's/GO_SERVER=.*/GO_SERVER='$GO_SERVER'/' /etc/default/go-agent

mkdir -p /var/lib/go-agent/config
/bin/rm -f /var/lib/go-agent/config/autoregister.properties

AGENT_KEY="${AGENT_KEY:-123456789abcdef}"
echo "agent.auto.register.key=$AGENT_KEY" >/var/lib/go-agent/config/autoregister.properties

if [ -n "$AGENT_RESOURCES" ]; then echo "agent.auto.register.resources=$AGENT_RESOURCES" >>/var/lib/go-agent/config/autoregister.properties; fi
if [ -n "$AGENT_ENVIRONMENTS" ]; then echo "agent.auto.register.environments=$AGENT_ENVIRONMENTS" >>/var/lib/go-agent/config/autoregister.properties; fi

/sbin/setuser go /etc/init.d/go-agent start
exec /usr/share/go-agent/agent.sh