Skip to content

Commit ca47122

Browse files
authored
Merge pull request #4 from rgrizzell/9.x
Docker updates
2 parents e96e7c1 + fa8b7b7 commit ca47122

File tree

6 files changed

+116
-2
lines changed

6 files changed

+116
-2
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
README.md
2+
LICENSE
3+
.gitignore
4+
.github

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM debian:12-slim as build
22
ARG VERSION=9.0.5
3+
ARG VARIANT=container
4+
ARG MICROPYPATH=/ciruitpy/lib
35

46
# Install system requirements
57
RUN apt update \
@@ -12,17 +14,22 @@ RUN python3 -m venv .venv
1214
ENV PATH="/circuitpython/.venv/bin:$PATH"
1315
RUN python3 -m pip install --upgrade -r requirements-dev.txt \
1416
&& python tools/ci_fetch_deps.py tests
17+
# Add the custom Unix port variants
18+
COPY variants/ /circuitpython/ports/unix/variants/
1519
# Build the binaires
1620
RUN make -C mpy-cross \
17-
&& make -C ports/unix
21+
&& VARIANT=$VARIANT BUILD=build make -C ports/unix
1822

1923
# Create final runtime container
2024
FROM debian:12-slim
2125
COPY --from=build /circuitpython/mpy-cross/build/mpy-cross /usr/local/bin/mpy-cross
22-
COPY --from=build /circuitpython/ports/unix/build-standard/micropython /usr/local/bin/micropython
26+
COPY --from=build /circuitpython/ports/unix/build/micropython /usr/local/bin/micropython
27+
# Setup non-root runtime user
2328
RUN useradd -Md /circuitpy circuitpy \
2429
&& mkdir /circuitpy \
2530
&& chown circuitpy:circuitpy /circuitpy
2631
USER circuitpy
2732
WORKDIR /circuitpy
33+
# Load libraries from the working directory
34+
ENV MICROPYPATH=$MICROPYPATH
2835
ENTRYPOINT ["/usr/local/bin/micropython"]

variants/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Variants
2+
Unix ports of CircuitPython (and MicroPython) use variants instead of board definitions. These variants are used to build versions of CircuitPython intended mostly for testing purposes.
3+
4+
The `coverage` variant is compiled with most libraries, but also contains debug and profiling extras that may not be desired. The `standard`, `minimal`, and `nanbox` variants exist, do not contain any of the built-in CircuitPython libraries. The `minimal` and `nanbox` variants have even less features enabled.
5+
6+
In order to build a version of CircuitPython with the libraries and without the debug hooks, a new variant must be defined. This is the `container` variant.
7+
8+
For more details on the types of available variant definitions, see the CircuitPython repository: https://github.com/adafruit/circuitpython/tree/main/ports/unix/variants
9+
10+
## Building
11+
12+
Contents of this directory is copied to `/circuitpython/ports/unix/variants/` before being compiled.
13+
14+
By default, the `container` variant is used, however custom variants can be built by setting the `VARIANT` build arg to the name of the custom variant's directory. For example a variant titled `mycustomvariant` would be built with the following command.
15+
16+
```text
17+
docker build -t circuitpython --build-arg="VARIANT=mycustomvariant" .
18+
```

variants/container/manifest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include("$(PORT_DIR)/variants/manifest.py")

variants/container/mpconfigvariant.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Damien P. George
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// Set base feature level.
28+
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES)
29+
30+
// Enable extra Unix features.
31+
#include "../mpconfigvariant_common.h"
32+
33+
// CIRCUITPY-CHANGE: Disable things never used in circuitpython
34+
#define MICROPY_PY_CRYPTOLIB (0)
35+
#define MICROPY_PY_CRYPTOLIB_CTR (0)
36+
#define MICROPY_PY_STRUCT (0) // uses shared-bindings struct

variants/container/mpconfigvariant.mk

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This is the default variant when you `make` the Unix port.
2+
FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
3+
4+
SRC_BITMAP := \
5+
shared/runtime/context_manager_helpers.c \
6+
displayio_min.c \
7+
shared-bindings/__future__/__init__.c \
8+
shared-bindings/aesio/aes.c \
9+
shared-bindings/aesio/__init__.c \
10+
shared-bindings/bitmapfilter/__init__.c \
11+
shared-bindings/bitmaptools/__init__.c \
12+
shared-bindings/codeop/__init__.c \
13+
shared-bindings/displayio/Bitmap.c \
14+
shared-bindings/displayio/ColorConverter.c \
15+
shared-bindings/displayio/Palette.c \
16+
shared-bindings/getpass/__init__.c \
17+
shared-bindings/locale/__init__.c \
18+
shared-bindings/traceback/__init__.c \
19+
shared-bindings/util.c \
20+
shared-bindings/zlib/__init__.c \
21+
shared-module/aesio/aes.c \
22+
shared-module/aesio/__init__.c \
23+
shared-module/bitmapfilter/__init__.c \
24+
shared-module/bitmaptools/__init__.c \
25+
shared-module/displayio/area.c \
26+
shared-module/displayio/Bitmap.c \
27+
shared-module/displayio/ColorConverter.c \
28+
shared-module/displayio/Palette.c \
29+
shared-module/getpass/__init__.c \
30+
shared-module/os/getenv.c \
31+
shared-module/struct/__init__.c \
32+
shared-module/traceback/__init__.c \
33+
shared-module/zlib/__init__.c \
34+
35+
SRC_C += $(SRC_BITMAP)
36+
37+
CFLAGS += \
38+
-DCIRCUITPY_AESIO=1 \
39+
-DCIRCUITPY_BITMAPTOOLS=1 \
40+
-DCIRCUITPY_CODEOP=1 \
41+
-DCIRCUITPY_DISPLAYIO_UNIX=1 \
42+
-DCIRCUITPY_FUTURE=1 \
43+
-DCIRCUITPY_GETPASS=1 \
44+
-DCIRCUITPY_LOCALE=1 \
45+
-DCIRCUITPY_OS_GETENV=1 \
46+
-DCIRCUITPY_STRUCT=1 \
47+
-DCIRCUITPY_TRACEBACK=1 \
48+
-DCIRCUITPY_ZLIB=1

0 commit comments

Comments
 (0)