Skip to content

Commit d737e10

Browse files
authored
Add Dockerfile to project (#710)
The integration tests require RVM to run. Without them they can't run. Added Dockerfile to make it easier to run the project in an isolated environment.
1 parent 3f0b6b3 commit d737e10

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Dockerfile
2+
coverage

Dockerfile

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
##
2+
# Usage:
3+
#
4+
# # build the image
5+
# docker build -t annotate-docker .
6+
#
7+
# # run a bash login shell in a container running that image
8+
# docker run -it annotate-docker bash -l
9+
#
10+
# References:
11+
# https://github.com/ms-ati/docker-rvm/blob/master/Dockerfile
12+
# https://hub.docker.com/r/instructure/rvm/dockerfile
13+
##
14+
15+
FROM ubuntu:18.04
16+
17+
ARG RVM_USER=docker
18+
19+
# RVM version to install
20+
ARG RVM_VERSION=stable
21+
22+
# Directorry path
23+
ARG PROJECT_PATH=/annotate_models
24+
25+
# Install RVM
26+
RUN apt-get update \
27+
&& apt-get install -y \
28+
curl \
29+
git \
30+
gnupg2 \
31+
&& apt-get clean \
32+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/
33+
34+
RUN addgroup --gid 9999 ${RVM_USER} \
35+
&& adduser --uid 9999 --gid 9999 --disabled-password --gecos "Docker User" ${RVM_USER} \
36+
&& usermod -L ${RVM_USER}
37+
38+
# No ipv6 support in container (https://github.com/inversepath/usbarmory-debian-base_image/issues/)
39+
RUN mkdir ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf
40+
41+
# https://superuser.com/questions/954509/what-are-the-correct-permissions-for-the-gnupg-enclosing-folder-gpg-warning
42+
RUN chmod 700 ~/.gnupg && chmod 600 ~/.gnupg/*
43+
44+
# Install + verify RVM with gpg (https://rvm.io/rvm/security)
45+
RUN gpg2 --quiet --no-tty --logger-fd 1 --keyserver hkp://keys.gnupg.net \
46+
--recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \
47+
7D2BAF1CF37B13E2069D6956105BD0E739499BDB \
48+
&& echo 409B6B1796C275462A1703113804BB82D39DC0E3:6: | \
49+
gpg2 --quiet --no-tty --logger-fd 1 --import-ownertrust \
50+
&& curl -sSO https://raw.githubusercontent.com/rvm/rvm/${RVM_VERSION}/binscripts/rvm-installer \
51+
&& curl -sSO https://raw.githubusercontent.com/rvm/rvm/${RVM_VERSION}/binscripts/rvm-installer.asc \
52+
&& gpg2 --quiet --no-tty --logger-fd 1 --verify rvm-installer.asc \
53+
&& bash rvm-installer ${RVM_VERSION} \
54+
&& rm rvm-installer rvm-installer.asc \
55+
&& echo "bundler" >> /usr/local/rvm/gemsets/global.gems \
56+
&& echo "rvm_silence_path_mismatch_check_flag=1" >> /etc/rvmrc \
57+
&& echo "install: --no-document" > /etc/gemrc
58+
59+
# Workaround tty check, see https://github.com/hashicorp/vagrant/issues/1673#issuecomment-26650102
60+
RUN sed -i 's/^mesg n/tty -s \&\& mesg n/g' /root/.profile
61+
62+
# Switch to a bash login shell to allow simple 'rvm' in RUN commands
63+
SHELL ["/bin/bash", "-l", "-c"]
64+
RUN rvm group add rvm "${RVM_USER}"
65+
66+
# Create project directory and copy path
67+
RUN mkdir -p /${PROJECT_PATH} && chown ${RVM_USER}:${RVM_USER} /${PROJECT_PATH}
68+
COPY . /${PROJECT_PATH}
69+
70+
# Switch to user
71+
USER ${RVM_USER}
72+
RUN echo ". /etc/profile.d/rvm.sh" >> ~/.bashrc
73+
74+
WORKDIR ${PROJECT_PATH}

0 commit comments

Comments
 (0)