Skip to content

Commit c40be3a

Browse files
author
Michael Ricks-Aherne
committed
VSCode setup for containerized dev
1 parent 450b513 commit c40be3a

File tree

7 files changed

+94
-0
lines changed

7 files changed

+94
-0
lines changed

.devcontainer/Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [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
4+
ARG VARIANT="3.10-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6+
ENV PYTHONUNBUFFERED 1
7+
WORKDIR /workspaces/Slay-The-Spire-in-Python
8+
RUN /usr/local/py-utils/bin/pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' isort && \
9+
/usr/local/py-utils/bin/pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' poetry && \
10+
pip install --upgrade pip
11+
RUN chown -R vscode:vscode /home/vscode/.config && \
12+
/usr/local/py-utils/bin/poetry completions bash > /etc/bash_completion.d/poetry.bash-completion
13+
14+
15+

.devcontainer/devcontainer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "Python 3",
5+
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
"context": "..",
9+
"args": {
10+
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
11+
// Append -bullseye or -buster to pin to an OS version.
12+
// Use -bullseye variants on local on arm64/Apple Silicon.
13+
"VARIANT": "3.10",
14+
// Options
15+
"POETRY_VERSION": "1.1.13"
16+
}
17+
},
18+
19+
// Set *default* container specific settings.json values on container create.
20+
"settings": {
21+
"python.defaultInterpreterPath": "/usr/local/bin/python",
22+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
23+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
24+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
25+
"python.analysis.lintingEnabled": true,
26+
"python.analysis.linter": "pylint",
27+
"python.analysis.linting.pylintArgs": ["--rcfile", "/path/to/your/.pylintrc"]
28+
},
29+
// Add the IDs of extensions you want installed when the container is created.
30+
"extensions": [
31+
"ms-python.python",
32+
"ms-python.vscode-pylance",
33+
"ms-python.pylint"
34+
],
35+
36+
// Use 'postCreateCommand' to run commands after the container is created.
37+
"postCreateCommand": "bash ./.devcontainer/post-install.sh"
38+
39+
// Configure tool-specific properties.
40+
// "customizations": {},
41+
42+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
43+
// "remoteUser": "root"
44+
}

.devcontainer/post-install.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# Placeholder
4+
echo "Running post-install.sh"
5+
poetry install --no-root

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.dockerignore
2+
.env
3+
.venv
4+
.pytest_cache
5+
.pythonlibs
6+
__pycache__

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,19 @@ A text based version of Slay the Spire coded in python
33
I have no idea how to release the game so just fork the repo and run it in a code editor
44

55
DISCLAIMER: I am not a professional, if you wonder why the code sucks, that's why.
6+
7+
8+
## VSCode Dev Environment
9+
10+
If using VSCode, there is a devcontainer that can be used to get up and running quickly. This will install all the dependencies and allow you to run the game.
11+
12+
Quick Start:
13+
- Install [VSCode](https://code.visualstudio.com/)
14+
- Install [Docker](https://www.docker.com/)
15+
- Install [Devcontainer](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) VSCode Extension
16+
- Open the project in VSCode
17+
- Click the green button in the bottom left corner of VSCode
18+
- Select `Dev Container: Reopen in Container`
19+
- Wait for the container to build
20+
- Open a terminal in VSCode
21+
- Run `./scripts/play.sh` to start the game or `./scripts/test.sh` to run the tests

scripts/play.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
# Convenience script for running tests locally. Run this from the root of the project.
4+
poetry run python main.py

scripts/test.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
# Convenience script for running tests locally.
4+
poetry run pytest -s --full-trace

0 commit comments

Comments
 (0)