Skip to content

Commit c0007ef

Browse files
authored
Merge pull request #2 from faasm/toolchain-split
Self-contained container build
2 parents 5fe3a30 + 379c854 commit c0007ef

File tree

18 files changed

+289
-96
lines changed

18 files changed

+289
-96
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
if: github.event.pull_request.draft == false
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- name: "Get the latest code"
15+
uses: actions/checkout@v2
16+
- name: "Submodules"
17+
run: "git submodule update --init --recursive"
18+
- name: "Install requirements"
19+
run: "pip3 install -r requirements.txt"
20+
- name: "Run Black"
21+
run: "python3 -m black --check $(git ls-files '*.py')"
22+
- name: "Set up QEMU"
23+
uses: docker/setup-qemu-action@v1
24+
- name: "Set up Docker Buildx"
25+
uses: docker/setup-buildx-action@v1
26+
- name: "Build the sysroot container"
27+
id: docker_build
28+
uses: docker/build-push-action@v2
29+
with:
30+
push: false
31+
context: .
32+
file: docker/cpython.dockerfile
33+

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: "Get the code"
13+
uses: actions/checkout@v2
14+
- name: "Submodules"
15+
run: "git submodule update --init --recursive"
16+
- name: "Get tag version"
17+
run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_ENV
18+
- name: "Print tag version"
19+
run: echo ${{ env.TAG_VERSION }}
20+
- name: "Set up QEMU"
21+
uses: docker/setup-qemu-action@v1
22+
- name: "Set up Docker Buildx"
23+
uses: docker/setup-buildx-action@v1
24+
- name: "Log in to DockerHub"
25+
uses: docker/login-action@v1
26+
with:
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
- name: "Build and push sysroot container"
30+
id: docker_build
31+
uses: docker/build-push-action@v2
32+
with:
33+
push: true
34+
file: docker/cpython.dockerfile
35+
context: .
36+
tags: faasm/cpython:${{ env.TAG_VERSION }}

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,3 @@
2121
path = third-party/mxnet
2222
url = https://github.com/faasm/incubator-mxnet
2323
branch = faasm
24-
[submodule "third-party/libffi"]
25-
path = third-party/libffi
26-
url = https://github.com/faasm/libffi.git

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ CPython is built statically, some notes on this process can be found
3131
Several of the code changes to CPython and numpy were borrowed from
3232
[pyodide](https://github.com/iodide-project/pyodide).
3333

34+
## Releasing
35+
36+
This repo gets built as a container, `faasm/cpython`. If you want to release a
37+
new version, you can:
38+
39+
- Update the version in `VERSION`
40+
- Run `git.tag`
41+
- Let the Github action do the rest
42+
3443
## Set-up
3544

3645
### Submodules

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.6

bin/crossenv_setup.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ BUILD_PYTHON_BIN=/usr/local/faasm/python3.8/bin
1111
BUILD_PYTHON=${BUILD_PYTHON_BIN}/python3.8
1212
BUILD_PIP=${BUILD_PYTHON_BIN}/pip3.8
1313

14-
FAASM_DIR=/usr/local/code/faasm
15-
FAASMCLI=${FAASM_DIR}/faasmcli
16-
1714
# Install the build machine python dependencies
1815
CROSSENV_SRC_DIR=${PROJ_ROOT}/third-party/crossenv
1916
echo "Installing crossenv from ${CROSSENV_SRC_DIR}"
@@ -27,11 +24,6 @@ ${BUILD_PIP} install cython
2724
echo "Installing invoke"
2825
${BUILD_PIP} install invoke
2926

30-
echo "Installing Faasmcli"
31-
pushd ${FAASMCLI} >> /dev/null
32-
${BUILD_PIP} install .
33-
popd >> /dev/null
34-
3527
# Run the set-up script
3628
pushd ${PROJ_ROOT} >> /dev/null
3729
${BUILD_PYTHON} bin/crossenv_setup.py

docker/cpython.dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM faasm/sysroot:0.0.10
2+
3+
RUN apt install -y \
4+
libssl-dev \
5+
ninja-build
6+
7+
WORKDIR /code/faasm-cpython
8+
COPY requirements.txt .
9+
RUN pip3 install -r requirements.txt
10+
11+
# Install build Python (careful with Docker cache here)
12+
COPY bin/install_build_python.sh bin/install_build_python.sh
13+
RUN ./bin/install_build_python.sh
14+
15+
# Add the rest of the code
16+
COPY . .
17+
18+
# Build CPython
19+
RUN inv cpython
20+
21+
# Set up crossenv
22+
RUN ./bin/crossenv_setup.sh
23+
24+
# Install cross-compiled python packages
25+
RUN . ./cross_venv/bin/activate && inv libs.install
26+
27+
# TODO - enable these once the MXNet/ Horovod work is completed
28+
# Build mxnet
29+
# RUN inv mxnet
30+
31+
# Install experimental pacakges
32+
# RUN . ./cross_venv/bin/activate && inv libs.install --experimental
33+
34+
# Copy files into place
35+
RUN inv runtime

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
black
2+
invoke

tasks/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
from invoke import Collection
22

33
from . import (
4+
container,
45
cpython,
6+
git,
57
libs,
68
mxnet,
7-
ffi,
9+
runtime,
810
)
911

1012
ns = Collection(
13+
container,
1114
cpython,
15+
git,
1216
libs,
1317
mxnet,
14-
ffi,
18+
runtime,
1519
)

tasks/container.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from invoke import task
2+
from os.path import join
3+
4+
from faasmtools.docker import (
5+
build_container,
6+
push_container,
7+
)
8+
9+
from tasks.env import (
10+
PROJ_ROOT,
11+
get_version,
12+
)
13+
14+
CONTAINER_IMAGE = "faasm/cpython"
15+
DOCKERFILE = join(PROJ_ROOT, "docker", "cpython.dockerfile")
16+
17+
18+
def _get_tag():
19+
tag_name = "{}:{}".format(CONTAINER_IMAGE, get_version())
20+
return tag_name
21+
22+
23+
@task(default=True)
24+
def build(ctx, nocache=False, push=False):
25+
"""
26+
Build current version of the cpython container
27+
"""
28+
build_container(
29+
_get_tag(), DOCKERFILE, PROJ_ROOT, nocache=nocache, push=push
30+
)
31+
32+
33+
@task
34+
def push(ctx):
35+
"""
36+
Push the current version of the cpython container
37+
"""
38+
push_container(_get_tag())

0 commit comments

Comments
 (0)