Skip to content

Commit

Permalink
add dev image
Browse files Browse the repository at this point in the history
  • Loading branch information
sjev committed May 1, 2024
1 parent 9bc9a2b commit 987557a
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Push docker images

on:
push:
branches:
- main
paths:
- "docker/**"
- ".github/workflows/build-images.yml"

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: mkdocs
USERNAME: ${{ github.repository_owner }}
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build dev image
run: |
cd docker/dev
docker build . -t ghcr.io/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest
- name: Push Docker image to GitHub Container Registry
run: docker push ghcr.io/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest
74 changes: 74 additions & 0 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM python:3-slim

ARG USERNAME=dev
ARG UID=1000
ARG GID=1000
ARG VERSION="python-dev"

# Create the user
RUN groupadd --gid $GID $USERNAME \
&& useradd --uid $UID --gid $GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# dialout group
RUN usermod -a -G dialout $USERNAME

# install packages
RUN apt-get install -y \
locales \
tree \
git \
git-lfs \
mosquitto-clients \
iputils-ping \
picocom \
socat \
libgl1 \
rsync \
graphviz

# cleanup
RUN rm -rf /var/lib/apt/lists/*

# set locale
RUN export LC_ALL=en_US.UTF-8
RUN export LANG=en_US.UTF-8
RUN locale-gen en_US.UTF-8

RUN pip install --upgrade pip


USER ${USERNAME}
RUN echo 'export PS1="🐍 \[\033[1;36m\]'"${VERSION}"' \[\e[33m\]\W\[\e[m\] \[\033[1;36m\]# \[\033[0m\]"' >> ~/.bashrc

# add local bin to path
RUN echo "export PATH=\$PATH:/home/${USERNAME}/.local/bin" >> ~/.bashrc
ENV PATH="${PATH}:/home/${USERNAME}/.local/bin"

WORKDIR /home/${USERNAME}


# setup folders for saving vscode extensions
# https://code.visualstudio.com/remote/advancedcontainers/avoid-extension-reinstalls
RUN mkdir -p /home/$USERNAME/.vscode-server/extensions \
&& chown -R $USERNAME \
/home/$USERNAME/.vscode-server


# install requirements
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt && rm requirements.txt


# build timestamp
USER root
RUN echo ${VERSION} >> /build_date.txt && \
date >> /build_date.txt

USER ${USERNAME}
WORKDIR /home/${USERNAME}
28 changes: 28 additions & 0 deletions docker/dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
black
build
bumpversion
click
coloredlogs
coverage
invoke
ipython
jupyterlab
matplotlib
mkdocs
mkdocs-glightbox
mkdocs-jupyter
mkdocs-macros-plugin
mkdocs-material
mkdocs-mermaid2-plugin
mkdocstrings
mkdocstrings-python
mypy
numpy
orjson
pre-commit
pydantic
pylint
pytest
pytest-asyncio
pytest-cov
ruff
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Constants
CI_IMG = "roxbot-ci"
MKDOCS_IMG = "roxbot-mkdocs"


@task
Expand Down

0 comments on commit 987557a

Please sign in to comment.