Skip to content

Commit

Permalink
feat: #706 Adding initial Dev Container
Browse files Browse the repository at this point in the history
  • Loading branch information
robbrad committed May 14, 2024
1 parent ae961f1 commit a4da784
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 2 deletions.
41 changes: 41 additions & 0 deletions .devcontainer/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG VARIANT="3.11-bullseye"
FROM mcr.microsoft.com/devcontainers/python:${VARIANT} AS ukbc-dev-base

USER vscode

# Define the version of Poetry to install (default is 1.4.2)
# Define the directory of python virtual environment
ARG PYTHON_VIRTUALENV_HOME=/home/vscode/ukbc-py-env \
POETRY_VERSION=1.5.1

ENV POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_NO_INTERACTION=true

# Install Poetry outside of the v`irtual environment to avoid conflicts
RUN python3 -m pip install --user pipx && \
python3 -m pipx ensurepath && \
pipx install poetry==${POETRY_VERSION}

# Create a Python virtual environment for the project
RUN python3 -m venv ${PYTHON_VIRTUALENV_HOME} && \
$PYTHON_VIRTUALENV_HOME/bin/pip install --upgrade pip

ENV PATH="$PYTHON_VIRTUALENV_HOME/bin:$PATH" \
VIRTUAL_ENV=$PYTHON_VIRTUALENV_HOME

# Setup for bash
RUN poetry completions bash >> /home/vscode/.bash_completion && \
echo "export PATH=$PYTHON_VIRTUALENV_HOME/bin:$PATH" >> ~/.bashrc

# Set the working directory for the app
WORKDIR /workspaces/ukbc

# Use a multi-stage build to install dependencies
FROM ukbc-dev-base AS ukbc-dev-dependencies

ARG PYTHON_VIRTUALENV_HOME

COPY / /workspaces/ukbc/

RUN poetry install --no-interaction --no-ansi --with dev
#docker build -f .devcontainer/dev.Dockerfile -t ukbc_dev_container .
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
"settings": {
"python.defaultInterpreterPath": "/home/vscode/ukbc-py-env",
"python.testing.pytestArgs": [
"uk_bin_collection",
"--headless=True"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
}
}
}
29 changes: 29 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
devcontainer:
image: ukbc_dev_container # This tags the built image
build:
context: ../ # Path to the directory containing the Dockerfile
dockerfile: .devcontainer/dev.Dockerfile
volumes:
- ../..:/workspaces:cached
networks:
- devnet
depends_on:
- selenium
command: sleep infinity

selenium:
image: selenium/standalone-chrome:latest
networks:
- devnet
ports:
- "4444:4444"
- "7900:7900"
shm_size: 2gb
hostname: selenium
privileged: true
restart: always

networks:
devnet:
driver: bridge
38 changes: 38 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ignore everything
*

# But not these files...
!*.json
!*.py
!PipFile
!Pipfile.lock
!.gitignore
!.dockerignore
!*.toml
!*.md
!*.rst
!LICENSE
!*.schema
!Makefile
!dependabot.yaml
!poetry.lock
!behave.ini
!*.Dockerfile

# Or these folders...
!.github
!*.png
!.github/ISSUE_TEMPLATE
!.github/ISSUE_TEMPLATE/*.yaml
!.github/workflows
!.github/workflows/*.yml
!uk_bin_collection
!uk_bin_collection/**/*
!uk_bin_collection_api_server
!uk_bin_collection_api_server/**/*
!wiki
!wiki/**/*
!custom_components
__pycache__
!TO_BE_CONVERTED
!.devcontainer
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
!PipFile
!Pipfile.lock
!.gitignore
!.dockerignore
!*.toml
!.md
!*.md
!*.rst
!LICENSE
!*.schema
!Makefile
!dependabot.yaml
!poetry.lock
!behave.ini
!*.Dockerfile
!docker-compose.yml

# Or these folders...
!.github
Expand All @@ -33,4 +36,4 @@
!custom_components
__pycache__
!TO_BE_CONVERTED

!.devcontainer

0 comments on commit a4da784

Please sign in to comment.