Last active
February 24, 2020 23:42
-
-
Save dmh2000/18ac03b002599bcc3c518fa93db35fb7 to your computer and use it in GitHub Desktop.
Sample Dockerfile with setup for development using Debian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# base linux with version | |
FROM debian:10.2 | |
# apt setup | |
RUN apt-get update | |
# unversioned tools | |
RUN apt-get install -y git | |
RUN apt-get install -y curl | |
RUN apt-get install -y bash-completion | |
RUN apt-get install -y vim | |
# tools with specific versions | |
RUN apt-get install -y build-essential=12.6 | |
RUN apt-get install -y python3=3.7.3-1 | |
# install Nodesource official instead of Debian default | |
# default Debian node doesn't install npm | |
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - | |
RUN apt-get install -y nodejs | |
# install latest GOLANG from google | |
RUN apt-get install wget | |
RUN wget https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz | |
RUN tar -C /usr/local -xzf go1.13.8.linux-amd64.tar.gz | |
# sudo | |
RUN apt-get -y install sudo | |
# set up ssh | |
RUN apt-get install -y openssh-server | |
RUN mkdir /var/run/sshd | |
# if you want to be able to ssh as root, uncomment these two line | |
# RUN echo 'root:awMAq68wvmwn' | chpasswd | |
# RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config | |
# SSH login fix. Otherwise user is kicked off after login | |
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | |
# make ssh visible to public access | |
ENV NOTVISIBLE "in users profile" | |
RUN echo "export VISIBLE=now" >> /etc/profile | |
# set up user | |
# for better security change this default password to something random | |
ARG USER=docker | |
ARG PW=docker | |
ARG UID=1000 | |
ARG GID=1000 | |
# add the user, set its password and add it to sudo group | |
RUN useradd -m ${USER} --uid=${UID} --shell=/bin/bash | |
RUN echo "${USER}:${PW}" | chpasswd | |
RUN adduser ${USER} sudo | |
# open port ssh port 22 | |
EXPOSE 22 | |
# start ssh daemon detacheds | |
CMD ["/usr/sbin/sshd","-D"] | |
# build command | |
# docker build -t debian-dev . - | |
# run command with container ssh port 22 mapped to localhost:32770 (set to whatever you want) | |
# docker run -p 32770:22 -d debian-dev | |
# removing | |
# docker ps | |
# docker kill <name> | |
# docker system prune | |
# docker rmi debian-dev | |
# GO | |
# cp setenv <container>:/home/docker | |
# export PATH=/usr/local/go/bin:$PATH | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment