-
Notifications
You must be signed in to change notification settings - Fork 0
Update dev container #3
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
base: feature/appcontainer
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,31 @@ | ||
| ARG PYTHON_VERSION=3.11 | ||
| FROM slackronyms:latest | ||
|
|
||
| FROM python:${PYTHON_VERSION} | ||
| # should match the version specified in terraform/pipeline/deploy.yml | ||
| ENV TF_VERSION="1.14.5" | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 \ | ||
| USER=compiler | ||
| # switch to root for package installation | ||
| USER root | ||
|
|
||
| # create non-root $USER and home directory | ||
| RUN useradd --create-home --shell /bin/bash $USER && \ | ||
| chown -R $USER /home/$USER | ||
| # install system packages that don't come preinstalled on Alpine | ||
| RUN apk add git \ | ||
| nodejs \ | ||
| npm \ | ||
| openssh-client | ||
|
|
||
| # switch to $USER | ||
| # switch back to $USER | ||
| USER $USER | ||
|
|
||
| # enter src directory | ||
| WORKDIR /home/$USER/src | ||
|
|
||
| # update PATH for local pip installs | ||
| ENV PATH="$PATH:/home/$USER/.local/bin" | ||
|
|
||
| # upgrade pip | ||
| RUN python -m pip install --upgrade pip | ||
|
|
||
| # copy assets | ||
| COPY . . | ||
|
|
||
| # install devcontainer requirements | ||
| # install devcontainer requirements (azure-cli and pre-commit) | ||
| COPY .devcontainer/requirements.txt .devcontainer/requirements.txt | ||
| RUN pip install --no-cache-dir -r .devcontainer/requirements.txt | ||
|
|
||
| # install docs requirements | ||
| COPY docs/requirements.txt docs/requirements.txt | ||
| RUN pip install --no-cache-dir -r docs/requirements.txt | ||
|
|
||
| # install pre-commit environments in throwaway Git repository | ||
| # https://stackoverflow.com/a/68758943 | ||
| COPY .pre-commit-config.yaml . | ||
| RUN git init . && \ | ||
| pre-commit install-hooks && \ | ||
| rm -rf .git | ||
|
|
||
| CMD sleep infinity | ||
|
|
||
| ENTRYPOINT [] |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| # initialize hook environments | ||
| git config --global --add safe.directory /$USER/app | ||
| pre-commit install --install-hooks --overwrite | ||
|
|
||
| # manage commit-msg hooks | ||
| pre-commit install --hook-type commit-msg |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| black | ||
| flake8 | ||
| isort | ||
| pre-commit | ||
| pytest |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [flake8] | ||
| max-line-length = 127 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ repos: | |
| rev: v0.48.0 | ||
| hooks: | ||
| - id: markdownlint | ||
| language_version: system | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a trick needed to get this to install on Alpine (in addition to installing |
||
|
|
||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| // 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": "Run Slack Bolt App", | ||
| "type": "debugpy", | ||
| "request": "launch", | ||
| "cwd": "${workspaceFolder}/slackronyms", | ||
| "program": "app.py", | ||
| "justMyCode": false, | ||
| "env": { | ||
| "PYTHONWARNINGS": "default" | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,17 @@ services: | |
| build: | ||
| context: . | ||
| dockerfile: .devcontainer/Dockerfile | ||
| image: compilerla/template-devcontainer:main | ||
| image: slackronyms:dev | ||
| env_file: .env | ||
| entrypoint: sleep infinity | ||
| volumes: | ||
| - ./:/home/compiler/src | ||
| - ./:/compiler/app | ||
|
|
||
| docs: | ||
| image: compilerla/template-devcontainer:main | ||
| image: slackronyms:dev | ||
| entrypoint: mkdocs | ||
| command: serve --dev-addr "0.0.0.0:8000" | ||
| command: serve --dev-addr "0.0.0.0:8001" | ||
| ports: | ||
| - "8000" | ||
| - "8001" | ||
| volumes: | ||
|
Comment on lines
+24
to
27
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 8001 matches what the Benefits does. I think switching to 8001 in template-devcontainer would be worthwhile, since 8000 is the default port for a lot of services that might be run for the primary purpose of your dev container. |
||
| - ./:/home/compiler/src | ||
| - ./:/compiler/app | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [tool.black] | ||
| line-length = 127 | ||
| target-version = ['py312'] | ||
| include = '\.pyi?$' | ||
|
|
||
| [tool.isort] | ||
| profile = "black" | ||
| combine_as_imports = true | ||
| line_length = 127 | ||
| skip_gitignore = true | ||
|
|
||
| [tool.pytest.ini_options] | ||
| testpaths = ["tests"] | ||
| log_file = "logs/pytest.log" | ||
| log_file_level = "DEBUG" | ||
| log_format = "%(asctime)s %(levelname)s %(message)s" | ||
| log_date_format = "%Y-%m-%d %H:%M:%S" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this from
postAttachCommandtopostCreateCommandafter stumbling into this old SO thread that Aidan Feldman had commented on a while ago. I can't recall what minor build issue led me there, but I got past it.Anyway, a commenter suggested that
postCreatewould be better since it should only need to run once when the devcontainer is (re)built. This works fine for me, but I admittedly didn't look into it any further to see if there's a reason we wouldn't want to do it post-create.