Created
March 1, 2021 18:27
-
-
Save capslocky/abde03c7f88239e5f4dc906091ff2cc8 to your computer and use it in GitHub Desktop.
My Development Machine for Node.js
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
alias rundev='docker run -it \ | |
--name dev \ | |
--rm \ | |
--publish 8080:8080 \ | |
--publish 8081:8081 \ | |
--publish 8082:8082 \ | |
--publish 8083:8083 \ | |
--publish 8087:8087 \ | |
--volume /volume_home_dev:/home/dev \ | |
--volume /var/run/docker.sock:/var/run/docker.sock \ | |
dev-01' | |
alias godev='docker exec -it dev bash' |
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
# build | |
docker build -t dev-01 . | |
# run container | |
docker run -it \ | |
--name dev \ | |
--rm \ | |
--publish 8080:8080 \ | |
--publish 8081:8081 \ | |
--publish 8082:8082 \ | |
--publish 8083:8083 \ | |
--publish 8087:8087 \ | |
--volume /volume_home_dev:/home/dev \ | |
--volume /var/run/docker.sock:/var/run/docker.sock \ | |
dev-01 | |
# attach to container | |
docker exec -it dev bash | |
# may be needed in bashrc | |
sudo chmod 666 /var/run/docker.sock |
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
FROM ubuntu:20.04 | |
LABEL description="My Development Machine for Node.js." | |
LABEL version="0.1" | |
LABEL maintainer="Baur Atanov" | |
ENV TERM=xterm-256color | |
USER root | |
WORKDIR /dockerfile_workdir | |
# in order to have help built-in documentation | |
RUN yes | unminimize | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update \ | |
&& apt-get install --yes curl tzdata | |
# timezone | |
ARG TZ=America/Chicago | |
RUN echo ${TZ} > /etc/timezone \ | |
&& rm /etc/localtime \ | |
&& ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ | |
&& dpkg-reconfigure -f noninteractive tzdata | |
# nodejs v12 from its offical repository | |
# standard utilities from default repository | |
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ | |
&& apt-get install --yes nodejs \ | |
&& apt-get install --yes --force-yes --no-install-recommends \ | |
sudo \ | |
man-db \ | |
less \ | |
wget \ | |
git \ | |
zip \ | |
unzip \ | |
htop \ | |
bind9-host \ | |
dnsutils \ | |
iputils-ping \ | |
netcat-openbsd \ | |
net-tools \ | |
telnet \ | |
nmap \ | |
tcpdump \ | |
whois \ | |
jq \ | |
vim \ | |
nano \ | |
groff \ | |
direnv \ | |
openssh-server \ | |
openssh-client \ | |
ca-certificates \ | |
cron \ | |
tmux \ | |
rsync \ | |
gcc \ | |
g++ \ | |
make | |
# already in the base image: | |
# grep | |
# gzip | |
# openssl | |
# sed | |
# tar | |
# npm packages | |
RUN npm install -g nodemon | |
# AWS CLI v2 | |
# taken from here https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html | |
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ | |
&& unzip awscliv2.zip \ | |
&& ./aws/install \ | |
&& rm awscliv2.zip \ | |
&& rm -rf aws | |
# Docker CLI client only | |
# taken from here https://stackoverflow.com/a/43594065/985457 | |
ARG DOCKERVERSION=18.06.3-ce | |
RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \ | |
&& tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 -C /usr/local/bin docker/docker \ | |
&& rm docker-${DOCKERVERSION}.tgz | |
# Kubernetis CLI client | |
RUN curl -LO "https://dl.k8s.io/release/v1.20.4/bin/linux/amd64/kubectl" \ | |
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \ | |
&& rm kubectl | |
# add new 'dev' user with sudo | |
# taken from here https://stackoverflow.com/a/58151889/985457 | |
ARG USERNAME=dev | |
RUN \ | |
groupadd -g 999 ${USERNAME} && useradd -u 999 -g ${USERNAME} -G sudo -m -s /bin/bash ${USERNAME} && \ | |
sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' && \ | |
sed -i /etc/sudoers -re 's/^root.*/root ALL=(ALL:ALL) NOPASSWD: ALL/g' && \ | |
sed -i /etc/sudoers -re 's/^#includedir.*/## **Removed the include directive** ##"/g' && \ | |
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
USER dev | |
WORKDIR /home/dev | |
CMD ["/bin/bash"] | |
# don't expose any ports here (in the image), just specify ports on run instead, like this: 'docker run -p 8085:8085' | |
# TODO setup openssh server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment