Last active
February 25, 2020 14:53
-
-
Save squizduos/923444355f90fe806d779e980018f502 to your computer and use it in GitHub Desktop.
code-server with Python, Go & Docker client
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
PASSWORD=b0120f0e54a74df3ddd9054f | |
CONFIG_GIST=85d9611ed9a7330e49a5ef4650c842e4 |
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
version: '2' | |
services: | |
nginx: | |
container_name: nginx | |
image: jwilder/nginx-proxy | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- "htpasswd:/etc/nginx/htpasswd" | |
- "vhost:/etc/nginx/vhost.d" | |
- "dhparam:/etc/nginx/dhparam" | |
- "html:/usr/share/nginx/html" | |
- "certs:/etc/nginx/certs:ro" | |
- "/var/run/docker.sock:/tmp/docker.sock:ro" | |
letsencrypt: | |
container_name: letsencrypt | |
image: jrcs/letsencrypt-nginx-proxy-companion | |
volumes: | |
- "certs:/etc/nginx/certs:rw" | |
- "/var/run/docker.sock:/var/run/docker.sock:ro" | |
volumes_from: | |
- "nginx" | |
code-server: | |
container_name: code-server | |
image: 'squizduos/dev-server:latest' | |
build: . | |
volumes: | |
- 'dev:/home/dev' | |
- '/var/run/docker.sock:/var/run/docker.sock' | |
expose: | |
- 8000 | |
environment: | |
- PASSWORD=b0120f0e54a74df3ddd9054f | |
- VIRTUAL_HOST=ide.sqds.me | |
- VIRTUAL_PORT=8000 | |
- LETSENCRYPT_HOST=ide.sqds.me | |
- LETSENCRYPT_EMAIL=sqds@cock.li | |
volumes: | |
dev: | |
external: true | |
htpasswd: | |
vhost: | |
dhparam: | |
html: | |
certs: | |
networks: | |
default: | |
external: | |
name: nginx-proxy |
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
#!/bin/bash | |
PUBLIC_IP=$(curl ifconfig.me) | |
if [ -z "${CONFIG_GIST}" ] | |
then | |
export CONFIG_GIST="85d9611ed9a7330e49a5ef4650c842e4"; | |
fi | |
bash sync-extensions.sh | |
if [ -z "${PASSWORD}" ] | |
then | |
export PASSWORD="changeme"; | |
fi | |
code-server --host 0.0.0.0 --port 8000 --auth "password" --disable-telemetry |
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:18.04 | |
LABEL ru.squizduos.image squizduos/dev-server | |
LABEL ru.squizduos.maintainer squizduos <squizduos@gmail.com> | |
LABEL ru.squizduos.url https://squizduos.ru | |
LABEL ru.squizduos.github https://github.com/squizduos | |
LABEL ru.squizduos.registry https://registry.squizduos.ru | |
ARG VERSION='2.1692-vsc1.39.2' | |
ENV TZ='Europe/Moscow' | |
ENV PASSWORD="changeme" | |
ENV LANG="ru_RU.UTF-8" | |
ARG DEBIAN_FRONTEND=noninteractive | |
# Set time zone | |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
# Install core dependencies | |
RUN apt-get update && \ | |
apt-get upgrade -y && \ | |
apt-get install -y \ | |
build-essential \ | |
ca-certificates \ | |
software-properties-common \ | |
apt-utils \ | |
dumb-init \ | |
curl \ | |
git \ | |
jq \ | |
locales \ | |
make \ | |
man-db \ | |
net-tools \ | |
openssl \ | |
screen \ | |
sudo \ | |
wget \ | |
unzip | |
# Locale Generation | |
RUN locale-gen en_US.UTF-8 && \ | |
locale-gen $LANG | |
ENV LOCALE=$LANG \ | |
LC_ALL='en_US.UTF-8' \ | |
SHELL=/bin/bash | |
# Install Coder | |
RUN export CODE_SERVER="code-server"$VERSION"-linux-x86_64" && \ | |
mkdir -p /tmp/data && \ | |
wget https://github.com/cdr/code-server/releases/download/"$VERSION"/${CODE_SERVER}.tar.gz -qO /tmp/data/${CODE_SERVER}.tar.gz && \ | |
tar -xzf /tmp/data/${CODE_SERVER}.tar.gz -C/tmp/data&& \ | |
mv /tmp/data/"$CODE_SERVER"/code-server /usr/local/bin && \ | |
rm -rf /tmp/data | |
# Add new user `dev` | |
RUN adduser --gecos '' --disabled-password dev && \ | |
echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd | |
USER dev | |
RUN mkdir -p /home/dev | |
WORKDIR /home/dev | |
VOLUME [ "/home/dev" ] | |
# Install all | |
COPY install.sh /tmp/install.sh | |
RUN sudo bash /tmp/install.sh | |
ENV GOROOT /usr/local/go | |
ENV PATH $PATH:/usr/local/go/bin | |
COPY sync-extensions.sh /usr/local/bin | |
COPY docker-entrypoint.sh /usr/local/bin | |
ENTRYPOINT ["dumb-init", "/usr/local/bin/docker-entrypoint.sh"] |
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
#/bin/bash | |
function install_cpp { | |
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" | |
} | |
function install_docker { | |
apt-get update | |
apt-get install -y docker.io docker-compose | |
usermod -aG docker dev | |
} | |
function install_golang { | |
curl -sS https://storage.googleapis.com/golang/go1.13.linux-amd64.tar.gz | tar -C /usr/local -xzf - | |
export GOROOT=/usr/local/go | |
export PATH=$PATH:/usr/local/go/bin | |
go get -u -v github.com/ramya-rao-a/go-outline | |
go get -u -v github.com/acroca/go-symbols | |
go get -u -v github.com/nsf/gocode | |
go get -u -v github.com/rogpeppe/godef | |
go get -u -v golang.org/x/tools/cmd/godoc | |
go get -u -v github.com/zmb3/gogetdoc | |
go get -u -v golang.org/x/lint/golint | |
go get -u -v github.com/fatih/gomodifytags | |
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs | |
go get -u -v golang.org/x/tools/cmd/gorename | |
go get -u -v sourcegraph.com/sqs/goreturns | |
go get -u -v github.com/cweill/gotests/... | |
go get -u -v golang.org/x/tools/cmd/guru | |
go get -u -v github.com/josharian/impl | |
go get -u -v github.com/haya14busa/goplay/cmd/goplay | |
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct | |
} | |
function install_java { | |
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections | |
apt-get update | |
apt-get -y install openjdk-8-jdk | |
} | |
function install_ngrok { | |
curl -Lo /tmp/ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip | |
unzip -o /tmp/ngrok.zip -d /usr/local/bin | |
rm -f /tmp/ngrok.zip | |
} | |
function install_nodejs { | |
# Install Node.js | |
curl -sL https://deb.nodesource.com/setup_11.x | bash - | |
# Install Yarn | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | |
apt-get update | |
apt-get install -y yarn nodejs | |
} | |
function install_python { | |
apt-get update | |
apt-get install -y python3 python3-dev python3-pip python3-venv | |
pip3 install python-language-server pipenv pylint | |
} | |
function install_rclone { | |
curl https://rclone.org/install.sh | sudo bash | |
} | |
install_cpp | |
install_docker | |
install_golang | |
install_java | |
install_ngrok | |
install_nodejs | |
install_python | |
install_rclone |
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
PROJECT=dev-server | |
AUTHOR=squziduos | |
PORT=8001 | |
VERSION=$(shell git rev-parse --short HEAD) | |
# HELP | |
# This will output the help for each task | |
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | |
.PHONY: help | |
help: ## This help. | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
.DEFAULT_GOAL := help | |
# DOCKER TASKS | |
# Build the container | |
build: ## Build the container | |
docker build --no-cache -t $(PROJECT):debug . | |
run: ## Run container on port configured in `config.env` | |
docker run -i -t --rm --env-file=debug.env -p=$(PORT):8000 -v "/var/run/docker.sock:/var/run/docker.sock" --name="$(PROJECT)-debug" $(PROJECT):debug | |
stop: ## Stop and remove a running container | |
docker stop $(PROJECT)-debug; docker rm $(PROJECT)-debug | |
# Docker publish | |
publish: repo-login publish-latest publish-version ## Publish the `{version}` ans `latest` tagged containers to ECR | |
publish-latest: tag-latest ## Publish the `latest` taged container to ECR | |
@echo 'publish $(AUTHOR)/$(PROJECT):latest to Docker Hub' | |
docker push $(AUTHOR)/$(PROJECT):latest | |
publish-version: tag-version ## Publish the `{version}` taged container to ECR | |
@echo 'publish $(AUTHOR)/$(PROJECT):$(VERSION) to Docker Hub' | |
docker push $(AUTHOR)/$(PROJECT):${VERSION} | |
# Docker tagging | |
tag: tag-latest tag-version ## Generate container tags for the `{version}` ans `latest` tags | |
tag-latest: ## Generate container `{version}` tag | |
@echo 'create tag latest' | |
docker tag $(PROJECT):debug $(AUTHOR)/$(PROJECT):latest | |
tag-version: ## Generate container `latest` tag | |
@echo 'create tag $(VERSION)' | |
docker tag $(PROJECT):debug $(AUTHOR)/$(PROJECT):$(VERSION) | |
repo-login: | |
docker login |
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
#!/bin/bash | |
if [ -z "${CONFIG_GIST}" ] | |
then | |
echo "Settings gist is not provided; exiting" | |
exit 0; | |
fi | |
echo "Updating settings from gist ${CONFIG_GIST}" | |
GIST_URL="https://gist.github.com/${CONFIG_GIST}.git" | |
TEMP_DIR="/tmp/cloudSettings" | |
SETTINGS_DIR=$HOME"/.local/share/code-server" | |
git clone "https://gist.github.com/${CONFIG_GIST}.git" ${TEMP_DIR} | |
rm -rf ${TEMP_DIR}/.git | |
cp ${TEMP_DIR}/* ${SETTINGS_DIR}/User/* | |
EXT_LIST=$(cat ${TEMP_DIR}/extensions.json | jq -r ".[].metadata.publisherId") | |
for line in $extensions; do | |
echo "Installing $line using VSCode"; | |
code-server --install-extension $line | |
done | |
rm ${TEMP_DIR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment