Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 824de05

Browse files
committed
refactor container build
1 parent 12f0140 commit 824de05

File tree

7 files changed

+87
-118
lines changed

7 files changed

+87
-118
lines changed

.containerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Dockerfile
2+
build/
3+
dist/
4+
.mypy_cache
5+
.tox
6+
.venv*

.devcontainer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// For format details, see https://aka.ms/devcontainer.json
2+
{
3+
"name": "Python 3 Developer Container",
4+
"build": {
5+
"dockerfile": "Dockerfile",
6+
"target": "build",
7+
"context": ".",
8+
"args": {}
9+
},
10+
"remoteEnv": {
11+
"DISPLAY": "${localEnv:DISPLAY}"
12+
},
13+
// Set *default* container specific settings.json values on container create.
14+
"settings": {
15+
"python.defaultInterpreterPath": "/usr/local/bin/python",
16+
"python.linting.enabled": true
17+
},
18+
// Add the IDs of extensions you want installed when the container is created.
19+
"extensions": [
20+
"ms-python.python",
21+
"ms-python.vscode-pylance"
22+
],
23+
// Make sure the files we are mapping into the container exist on the host
24+
"initializeCommand": "bash -c 'for i in $HOME/.inputrc $HOME/.bashrc_dev; do [ -f $i ] || touch $i; done'",
25+
"runArgs": [
26+
"--privileged",
27+
"--net=host",
28+
"-v=${localEnv:HOME}/.ssh:/root/.ssh",
29+
"-v=${localEnv:HOME}/.bashrc_dev:/root/.bashrc",
30+
"-v=${localEnv:HOME}/.inputrc:/root/.inputrc"
31+
],
32+
"mounts": [
33+
// map in home directory - not strictly necessary but useful
34+
"source=${localEnv:HOME},target=${localEnv:HOME},type=bind,consistency=cached"
35+
],
36+
// make the workspace folder the same inside and outside of the container
37+
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
38+
"workspaceFolder": "${localWorkspaceFolder}",
39+
// After the container is created, install the python project in editable form
40+
"postCreateCommand": "pip install $([ -f requirements_dev.txt ] && echo -r requirements_dev.txt ) -e .[dev]"
41+
}

.devcontainer/Dockerfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 68 deletions
This file was deleted.

.devcontainer/local_build.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/code.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ jobs:
215215
outputs: type=docker,dest=/tmp/image.tar
216216

217217
- name: show tags
218-
run: echo This is the tags generated by Docker meta
218+
run: |
219+
echo This is the tags generated by Docker meta
219220
echo ${{ steps.meta.outputs.tags }}
220221
221222
- name: Upload container image

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This file is for use as a devcontainer and a runtime container
2+
#
3+
# The devcontainer should use the build target and run as root and use podman
4+
# or docker with user namespaces.
5+
#
6+
7+
FROM python:3.10 as build
8+
9+
RUN apt-get update && apt-get upgrade -y && \
10+
apt-get install -y --no-install-recommends \
11+
build-essential \
12+
busybox \
13+
git \
14+
net-tools \
15+
vim \
16+
&& rm -rf /var/lib/apt/lists/* \
17+
&& busybox --install
18+
19+
RUN python3 -m venv /virtualenv
20+
ENV PATH=/virtualenv/bin:$PATH
21+
22+
COPY . /project
23+
24+
# verify that the wheel installs and runs with --version
25+
# replace python3-pip-skeleton if the cli command is different from repo name
26+
RUN cd /project && \
27+
pip install --upgrade pip build && \
28+
python -m build --sdist --wheel && \
29+
pip install dist/*.whl && \
30+
python3-pip-skeleton --version
31+
32+
FROM python:3.10-slim as runtime
33+
34+
COPY --from=build /virtualenv/ /virtualenv/
35+
ENV PATH=/virtualenv/bin:$PATH
36+
37+
ENTRYPOINT ["python3-pip-skeleton"]
38+
CMD ["--version"]

0 commit comments

Comments
 (0)