Fix #4. Needed to mount ~/.ssh and make sure that it has the same UID/GID as the host user

This commit is contained in:
Diego Ripley
2025-06-26 15:14:33 +00:00
parent a55e1d325d
commit 2f346bfa4c
2 changed files with 32 additions and 14 deletions
+8 -5
View File
@@ -3,6 +3,7 @@
"dockerComposeFile": "../docker-compose.yml", "dockerComposeFile": "../docker-compose.yml",
"service": "devcontainer", "service": "devcontainer",
"workspaceFolder": "/workspace", "workspaceFolder": "/workspace",
"containerUser": "ubuntu",
"shutdownAction": "stopCompose", "shutdownAction": "stopCompose",
"forwardPorts": [ "forwardPorts": [
5432, 5432,
@@ -14,13 +15,15 @@
"ms-python.python", "ms-python.python",
"ms-toolsai.jupyter", "ms-toolsai.jupyter",
"vsls-contrib.gistfs", "vsls-contrib.gistfs",
"vscode-icons-team.vscode-icons", "vscode-icons-team.vscode-icons"
"dorzey.vscode-sqlfluff"
], ],
"settings": { "settings": {
"python.pythonPath": "/root/.venv/bin/python", "python.pythonPath": "/home/ubuntu/.venv/bin/python",
"python.defaultInterpreterPath": "/root/.venv/bin/python" "python.defaultInterpreterPath": "/home/ubuntu/.venv/bin/python"
} }
} }
} },
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/home/ubuntu/.ssh,type=bind,consistency=cached"
]
} }
+23 -8
View File
@@ -1,10 +1,18 @@
FROM ghcr.io/osgeo/gdal:ubuntu-full-3.11.0 FROM ghcr.io/osgeo/gdal:ubuntu-full-3.11.0
# Ubuntu is UID 1000 and GID 1000
ARG USERNAME=ubuntu
USER root USER root
RUN apt-get update -y \ RUN apt-get update \
&& apt-get -y install gcc g++ make libsqlite3-dev zlib1g-dev && apt-get -y install gcc g++ make libsqlite3-dev zlib1g-dev
# Add user to sudoers
RUN apt-get -y install sudo \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME}
# Utilities # Utilities
RUN apt-get install -y neovim \ RUN apt-get install -y neovim \
python3-neovim \ python3-neovim \
@@ -30,23 +38,30 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="/usr/local/
# Create virtual environment and install Python packages # Create virtual environment and install Python packages
RUN uv venv ~/.venv \ RUN uv venv ~/.venv \
&& cd ~ \ && cd ~ \
&& uv pip install 'geopandas[all]' duckdb psycopg2-binary jupyterlab lonboard click stats-can openpyxl ordered-set sqlfluff buckaroo jenkspy 'polars[all]' && uv pip install 'geopandas[all]' duckdb psycopg2-binary jupyterlab lonboard click stats-can openpyxl ordered-set buckaroo jenkspy 'polars[all]'
# Bash Kernel # Bash Kernel
RUN cd ~ \ RUN cd ~ \
&& uv pip install bash_kernel \ && uv pip install bash_kernel \
&& /root/.venv/bin/python -m bash_kernel.install && /root/.venv/bin/python -m bash_kernel.install
# Install DuckDB
RUN mkdir -p ~/.local/bin \
&& curl https://install.duckdb.org | sh
# When user logs in, we use the spatial virtual environment # When user logs in, we use the spatial virtual environment
RUN echo 'source /root/.venv/bin/activate' > ~/.bashrc \ RUN echo 'source /home/'${USERNAME}'/.venv/bin/activate' > ~/.bashrc \
&& echo 'export PATH="~/.local/bin:${PATH}"' >> ~/.bashrc && echo 'export PATH="/home/'${USERNAME}'/.local/bin:${PATH}"' >> ~/.bashrc
RUN mv /root/.venv /home/${USERNAME} \
&& mv /root/.bashrc /home/${USERNAME} \
&& chown ${USERNAME}:${USERNAME} -R /home/${USERNAME}/.venv \
&& chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.bashrc
RUN mkdir /data RUN mkdir /data
RUN apt-get clean \ RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& uv cache clean && uv cache clean
USER ubuntu
# Install DuckDB
RUN mkdir -p ~/.local/bin \
&& curl https://install.duckdb.org | sh