Skip to content

Commit

Permalink
chore: add vscode dev container config. (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Apr 19, 2022
1 parent 0e05508 commit 3dec99b
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 2 deletions.
60 changes: 60 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM ubuntu:focal

# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
# this user's GID/UID must match your local user UID/GID to avoid permission issues
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
# https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=${USER_UID}

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -qy && apt-get install -qy \
apt-utils \
ca-certificates\
locales \
curl \
git \
make \
python-is-python3 \
python3 \
python3-pip \
ruby \
fish && \
apt-get autoclean -y && \
apt-get autoremove -y && \
apt-get clean

# Install xdrgen
RUN cd /opt && \
git clone --branch python-sdk https://github.com/overcat/xdrgen && \
cd xdrgen && \
gem build xdrgen.gemspec && \
gem install xdrgen-*.gem

# Install poetry
RUN pip install poetry

# Set up locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/fish --uid $USER_UID --gid $USER_GID -m $USERNAME \
# [Optional] Add sudo support for the non-root user
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=

USER $USERNAME

CMD ["/bin/fish"]
46 changes: 46 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/ubuntu-18.04-git
{
"name": "Stellar Python SDK Dev",
"dockerFile": "Dockerfile",
"build": {
"args": {}
},
// https://code.visualstudio.com/remote/advancedcontainers/environment-variables
"remoteEnv": {
// "PIP_INDEX_URL": "https://mirrors.ustc.edu.cn/pypi/web/simple"
},
// The optional 'runArgs' property can be used to specify additional runtime arguments.
"runArgs": [],
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
},
"fish": {
"path": "/bin/fish"
}
},
"terminal.integrated.defaultProfile.linux": "fish"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],
// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
// "portsAttributes": {
// },
// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
// "otherPortsAttributes": {
// "onAutoForward": "silent"
// },
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "poetry install",
"postAttachCommand": "poetry shell",
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": ["donjayamanne.python-extension-pack"],
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// On Linux, this will prevent new files getting created as root, but you may need to update the USER_UID
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
"remoteUser": "vscode"
}
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ clean:
find . -name \*.pyc -delete
.PHONY: clean

update-xdr:
download-xdr:
python .xdr/update_xdr.py
.PHONY: update-xdr
.PHONY: download-xdr

gen-xdr:
rm -rf stellar_sdk/xdr/*
xdrgen -o stellar_sdk/xdr -l python -n stellar .xdr/*.x
autoflake --in-place --ignore-init-module-imports --remove-all-unused-imports stellar_sdk/xdr/*.py
isort stellar_sdk/xdr/
black stellar_sdk/xdr/
.PHONY: gen-xdr

format:
autoflake --in-place --ignore-init-module-imports --remove-all-unused-imports .
Expand Down

0 comments on commit 3dec99b

Please sign in to comment.