Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dev Container #233

Merged
merged 10 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

RUN apt-get -y update && apt-get install -y ffmpeg

COPY Pipfile* /tmp/pip-tmp/
RUN cd /tmp/pip-tmp && pip install pipenv==2021.5.29 \
&& pipenv install --dev --deploy --system --ignore-pipfile
69 changes: 69 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/python-3
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.9",
// Options
"NODE_VERSION": "lts/*"
}
},

"remoteEnv": {
"PATH": "/home/vscode/.local/bin:${containerEnv:PATH}"
},

// Preserve shell history and stuff across rebuilds
"mounts": [
"source=profile,target=/root,type=volume",
"target=/root/.vscode-server,type=volume"
],

// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.blackPath": "/usr/local/bin/black",
"python.linting.flake8Path": "/usr/local/bin/flake8",
"python.linting.mypyPath": "/usr/local/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/bin/pycodestyle",
"python.linting.pylintPath": "/usr/local/bin/pylint"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"mutantdino.resourcemonitor",
"VisualStudioExptTeam.vscodeintellicode",
"KevinRose.vsc-python-indent",
"njpwerner.autodocstring",
"yzhang.markdown-all-in-one"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",
"postCreateCommand": "",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"git": "latest",
"github-cli": "latest",
"sshd": "latest",
"docker-in-docker": {
"version": "latest",
"moby": true,
},
}
}
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,18 @@ venv.bak/
# mypy
.mypy_cache/

#vscode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can exclude only launch.json and tasks.json from .gitignoge. Personal setting should be ignored.

.vscode
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

.history
.env

Expand Down
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Bot",
"type": "python",
"request": "launch",
"program": "bot/main.py",
"cwd": "${workspaceRoot}",
"preLaunchTask": "Run Bot Environment"
},
]
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks":
[
{
"label": "Run Bot Environment",
"type": "docker-compose",
"dockerCompose": {
"up": {
"detached": true,
"build": true,
"services": ["serving", "mongo"]
},
"files": [
"${workspaceFolder}/docker-compose-dev.yml"
]
}
}
]
}
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL = /bin/bash

.DEFAULT_GOAL := help
.PHONY: dev test lint start dev_build dev_start dev_test

Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "pypi"

[[description]]
name = "vldc-bot"
version = "0.6.10"
version = "0.6.11"
description = "VLDC nyan bot ^_^"
authors = [
#tg
Expand Down
26 changes: 13 additions & 13 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ The official [VLDC](https://vldc.org) telegram group bot.
* 🦠 covid mode – fun and gamez
* 🤫 nastya mode – stop. just stop

## Usage via VS Code (Easy Way)
Clone repository locally and open it up via VS Code and click Open in Container. Create `.env` file as described below.
Mongo will be available at `MONGO_HOST=localhost`. And you're done, you can run bot by clicking `F5` or `Run -> Launch Bot`.

Other option is to use [Codespaces](https://github.com/vldc-hq/vldc-bot/codespaces) from GitHub itself.

## Usage
Setup your env vars in `example.env` and rename it to `.env`. Don't push `.env` to public repos!
Expand Down