Skip to content

Commit

Permalink
add devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
weclaw1 committed Jun 9, 2024
1 parent a9b4107 commit 8a0eada
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 12 deletions.
34 changes: 34 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM python:3.8-slim-bookworm
ENV POETRY_VERSION=1.8.3 \
VIRTUAL_ENV=/venv \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false

RUN apt-get update && apt-get install -y \
curl \
binutils \
git \
nano \
python3-tk

ARG USERNAME=inbac
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

RUN mkdir -p $POETRY_HOME
RUN chown $USER_UID:$USER_GID $POETRY_HOME

RUN mkdir -p $VIRTUAL_ENV
RUN chown $USER_UID:$USER_GID $VIRTUAL_ENV

USER $USERNAME

ENV PATH="$POETRY_HOME/bin:$VIRTUAL_ENV/bin:$PATH"

RUN python -m venv $VIRTUAL_ENV
RUN curl -sSL https://install.python-poetry.org | python -
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Inbac",
"build": {
"dockerfile": "Dockerfile"
},

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-python.python"
]
}
}
}
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Dockerfile
LICENSE
README.md
.gitignore
.vscode/
.github/
Expand Down
50 changes: 40 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
FROM debian:12-slim AS build
ARG POETRY_VERSION=1.8.3

RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests \
python3-venv libpython3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
python3 -m venv /venv && \
/venv/bin/pip install --upgrade pip setuptools && \
/venv/bin/pip install poetry==${POETRY_VERSION}
FROM python:3.8-slim-bookworm AS build
ENV POETRY_VERSION=1.8.3 \
VIRTUAL_ENV=/venv \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false

RUN apt-get update && apt-get install -y \
curl \
binutils \
python3-tk

ENV PATH="$POETRY_HOME/bin:$VIRTUAL_ENV/bin:$PATH"

RUN python -m venv $VIRTUAL_ENV
RUN curl -sSL https://install.python-poetry.org | python -

WORKDIR /app

COPY . .

RUN poetry install && poetry run pyinstaller --onefile --windowed --hidden-import='PIL._tkinter_finder' inbac/inbac.py


FROM debian:12-slim
RUN apt-get update && apt-get install -y\
libxcb1 fonts-recommended

ARG USERNAME=inbac
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

COPY --from=build --chown=$USER_UID:$USER_GID /app/dist/inbac /inbac

USER $USERNAME
CMD ["/inbac"]
5 changes: 5 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

xhost +si:localuser:"$USER"
xhost +local:docker
docker run -it --rm -e DISPLAY="$DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix -v "$HOME":/home $(docker build -q .)

0 comments on commit 8a0eada

Please sign in to comment.