Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mgmt]: add sonic-mgmt docker for running test in sonic-mgmt repo #606

Merged
merged 2 commits into from
May 18, 2017
Merged
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
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,21 @@ DOCKER_BUILD = docker build --no-cache \
sonic-slave && \
docker tag $(SLAVE_IMAGE):latest $(SLAVE_IMAGE):$(SLAVE_TAG)

.PHONY: sonic-slave-build sonic-slave-bash

MGMT_TAG = $(shell shasum sonic-mgmt/Dockerfile | awk '{print substr($$1,0,11);}')
MGMT_IMAGE = sonic-mgmt-$(USER)

DOCKER_MGMT_BUILD = docker build --no-cache \
--build-arg user=$(USER) \
--build-arg uid=$(shell id -u) \
--build-arg guid=$(shell id -g) \
--build-arg hostname=$(shell echo $$HOSTNAME) \
-t $(MGMT_IMAGE) \
sonic-mgmt && \
docker tag $(MGMT_IMAGE):latest $(MGMT_IMAGE):$(MGMT_TAG)


.PHONY: sonic-slave-build sonic-slave-bash sonic-mgmt-build

.DEFAULT_GOAL := all

Expand All @@ -51,3 +65,6 @@ sonic-slave-bash :
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
$(DOCKER_BUILD) ; }
@$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash

sonic-mgmt-build :
@$(DOCKER_MGMT_BUILD)
70 changes: 70 additions & 0 deletions sonic-mgmt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM ubuntu:16.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install -y \
openssh-server \
gcc \
vim \
make \
git \
sudo \
python \
python-dev \
python-cffi \
libffi-dev \
libssl-dev \
sshpass \
libxml2 \
libxslt1-dev \
python-setuptools

# For JNLP launcher
RUN apt-get install -y default-jre

# For syslog test
RUN apt-get install -y rsyslog psmisc

RUN easy_install pip

RUN pip install ipaddr \
lxml \
netaddr \
natsort \
six \
pexpect \
pyasn1==0.1.9 \
pysnmp==4.2.5

RUN git clone https://github.com/ansible/ansible
RUN cd ansible && git checkout v2.0.0.2-1 -b v2.0.0.2-1 && git submodule update --init --recursive && make && make install

RUN mkdir /var/run/sshd
EXPOSE 22

# Add user
ARG user
ARG uid
ARG guid
ARG hostname

ENV BUILD_HOSTNAME $hostname
ENV USER $user

RUN groupadd -f -r -g $guid g$user

RUN useradd $user -l -u $uid -g $guid -d /var/$user -m -s /bin/bash

COPY sonic-jenkins.pub /var/$user/.ssh/authorized_keys2

RUN echo "Host *\n\tStrictHostKeyChecking no\n" > /var/$user/.ssh/config
RUN chown $user /var/$user/.ssh -R
RUN chmod go= /var/$user/.ssh -R

# Add user to sudoers
RUN echo "$user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers

USER $user

RUN cd /var/$user && git clone https://github.com/Azure/sonic-mgmt
1 change: 1 addition & 0 deletions sonic-mgmt/sonic-jenkins.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEJhhzQtlgNkBWxWXNm/qxZC26pFC16uOdGMx7BfMP9KxpKB46sFO5nkZXh8CiyjHitks2BYjbrK2IYubiyQhHaKh+4mnCnO58GLRRAiCUzeaC1jSrmqseBN8ZN7UV7gZUWQOxHErUHVhTbujUR0eZLymwPV0bNO9/bAWR5a+l5l/kf3VMREHF5Z6KyIuA9fT9XUJz8wLEUZCC8Id9RGwmKHS4FYuwtvcYm1MKb+ULXlri5o25G/X3I1pBpU/xUPBDUu+g3cIavrl7wVVGbIXYcYoH5qrTycMY0Y3rLBxu9SECUCqIxhnKQsiv+iXZSibnUXT4r6HcLMej5e+o1Jx3 lgh@jenkins-master-phx