Skip to content

Commit fc8e893

Browse files
MacOS and arm64 support, -slim image (#449)
1 parent ecb9822 commit fc8e893

File tree

130 files changed

+2436
-732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2436
-732
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@ replace = version = "{new_version}"
1111
[bumpversion:file:src/dipdup/__init__.py]
1212
search = __version__ = '{current_version}'
1313
replace = __version__ = '{new_version}'
14-
15-
[bumpversion:glob:src/*/docker/Dockerfile]
16-
search = FROM dipdup/dipdup:{current_version}
17-
replace = FROM dipdup/dipdup:{new_version}

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
!pyproject.toml
77
!poetry.lock
88
!README.md
9-
!inject_pyproject.sh
9+
!install_dependencies.sh
10+
!requirements**
1011

1112
# Add code
1213
!src/dipdup/

.github/workflows/build.yml

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ on:
55
- "**"
66
tags:
77
- '*.*.*'
8+
paths:
9+
- "src/**"
10+
- "Dockerfile"
11+
- "Dockerfile.slim"
12+
- "pyproject.toml"
13+
- "poetry.lock"
14+
- "Makefile"
15+
- ".github/workflows/build.yml"
816

917
jobs:
1018
build:
@@ -21,6 +29,9 @@ jobs:
2129
with:
2230
fetch-depth: 0
2331

32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v2
34+
2435
- name: Set up Docker Buildx
2536
uses: docker/setup-buildx-action@v2
2637
with:
@@ -33,24 +44,75 @@ jobs:
3344
username: ${{ github.actor }}
3445
password: ${{ secrets.GITHUB_TOKEN }}
3546

36-
- name: Set up metadata
37-
id: meta
47+
- name: Set up metadata (default)
48+
id: meta-default
3849
uses: docker/metadata-action@v3
3950
with:
4051
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
52+
flavor: |
53+
latest=false
4154
tags: |
4255
type=ref,event=branch
4356
type=ref,event=tag
57+
58+
- name: Set up metadata (pytezos)
59+
id: meta-pytezos
60+
uses: docker/metadata-action@v3
61+
with:
62+
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
63+
flavor: |
64+
latest=false
65+
suffix=-pytezos
66+
tags: |
67+
type=ref,event=branch
68+
type=ref,event=tag
69+
70+
- name: Set up metadata (slim)
71+
id: meta-slim
72+
uses: docker/metadata-action@v3
73+
with:
74+
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
4475
flavor: |
4576
latest=false
77+
suffix=-slim
78+
tags: |
79+
type=ref,event=branch
80+
type=ref,event=tag
4681
47-
- name: Publish image on GHCR
82+
- name: Publish nightly image (default)
4883
uses: docker/build-push-action@v3
4984
with:
5085
context: .
5186
file: Dockerfile
87+
platforms: linux/amd64,linux/arm64
88+
push: true
89+
cache-from: type=gha,scope=default
90+
cache-to: type=gha,scope=default,mode=max
91+
tags: ${{ steps.meta-default.outputs.tags }}
92+
labels: ${{ steps.meta-default.outputs.labels }}
93+
build-args: PYTEZOS=0
94+
95+
- name: Publish nightly image (pytezos)
96+
uses: docker/build-push-action@v3
97+
with:
98+
context: .
99+
file: Dockerfile
100+
platforms: linux/amd64,linux/arm64
101+
push: true
102+
cache-from: type=gha,scope=pytezos
103+
cache-to: type=gha,scope=pytezos,mode=max
104+
tags: ${{ steps.meta-pytezos.outputs.tags }}
105+
labels: ${{ steps.meta-pytezos.outputs.labels }}
106+
build-args: PYTEZOS=1
107+
108+
- name: Publish nightly image (slim)
109+
uses: docker/build-push-action@v3
110+
with:
111+
context: .
112+
file: Dockerfile.slim
113+
platforms: linux/amd64,linux/arm64
52114
push: true
53-
cache-from: type=gha
54-
cache-to: type=gha,mode=max
55-
tags: ${{ steps.meta.outputs.tags }}
56-
labels: ${{ steps.meta.outputs.labels }}
115+
cache-from: type=gha,scope=slim
116+
cache-to: type=gha,scope=slim,mode=max
117+
tags: ${{ steps.meta-slim.outputs.tags }}
118+
labels: ${{ steps.meta-slim.outputs.labels }}

.github/workflows/cookiecutter.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test cookiecutter
2+
on:
3+
push:
4+
paths:
5+
- "cookiecutter/**"
6+
- ".github/workflows/cookiecutter.yml"
7+
8+
jobs:
9+
test:
10+
name: Test cookiecutter
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out the repo
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: "3.10.x"
22+
23+
- name: Set up Poetry
24+
uses: snok/install-poetry@v1
25+
with:
26+
version: "1.1.13"
27+
28+
- name: Set up cache
29+
uses: actions/cache@v2
30+
id: cache-venv
31+
with:
32+
path: /home/runner/.cache/pypoetry/virtualenvs
33+
key: ${{ runner.os }}-venv-${{ hashFiles('**/cookiecutter/cookiecutter.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-venv-
36+
37+
- name: Create new project and ensure it's valid
38+
run: poetry run pip install cookiecutter && poetry run cookiecutter --no-input cookiecutter && cd my-dipdup-indexer && make all

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches:
88
- master
99
paths:
10-
- 'docs/**/*'
10+
- 'docs/**'
1111

1212
jobs:
1313
docs:

.github/workflows/release.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
username: ${{ secrets.DOCKER_USERNAME }}
2828
password: ${{ secrets.DOCKER_PASSWORD }}
2929

30-
- name: Set up metadata
31-
id: meta
30+
- name: Set up metadata (default)
31+
id: meta-default
3232
uses: docker/metadata-action@v3
3333
with:
3434
images: dipdup/dipdup
@@ -39,7 +39,7 @@ jobs:
3939
type=pep440,pattern={{major}}
4040
type=pep440,pattern={{major}}.{{minor}}
4141
42-
- name: Set up metadata (-pytezos)
42+
- name: Set up metadata (pytezos)
4343
id: meta-pytezos
4444
uses: docker/metadata-action@v3
4545
with:
@@ -51,6 +51,18 @@ jobs:
5151
type=pep440,pattern={{major}}-pytezos
5252
type=pep440,pattern={{major}}.{{minor}}-pytezos
5353
54+
- name: Set up metadata (slim)
55+
id: meta-slim
56+
uses: docker/metadata-action@v3
57+
with:
58+
images: dipdup/dipdup
59+
flavor: |
60+
latest=false
61+
tags: |
62+
type=pep440,pattern={{version}}-slim
63+
type=pep440,pattern={{major}}-slim
64+
type=pep440,pattern={{major}}.{{minor}}-slim
65+
5466
- name: Set up Python
5567
uses: actions/setup-python@v2
5668
with:
@@ -68,24 +80,37 @@ jobs:
6880
- name: Run tests
6981
run: make test
7082

71-
- name: Publish image on Docker Hub
83+
- name: Publish stable image (default)
7284
uses: docker/build-push-action@v2
7385
with:
7486
context: .
7587
file: Dockerfile
88+
platforms: linux/amd64,linux/arm64
7689
push: true
7790
tags: ${{ steps.meta.outputs.tags }}
7891
labels: ${{ steps.meta.outputs.labels }}
92+
build-args: PYTEZOS=0
7993

80-
- name: Publish image on Docker Hub (-pytezos)
94+
- name: Publish stable image (pytezos)
8195
uses: docker/build-push-action@v2
8296
with:
8397
context: .
8498
file: Dockerfile
99+
platforms: linux/amd64,linux/arm64
85100
push: true
86101
tags: ${{ steps.meta-pytezos.outputs.tags }}
87102
labels: ${{ steps.meta-pytezos.outputs.labels }}
88-
build-args: EXTRAS=pytezos
103+
build-args: PYTEZOS=1
104+
105+
- name: Publish stable image (slim)
106+
uses: docker/build-push-action@v3
107+
with:
108+
context: .
109+
file: Dockerfile.slim
110+
platforms: linux/amd64,linux/arm64
111+
push: true
112+
tags: ${{ steps.meta-slim.outputs.tags }}
113+
labels: ${{ steps.meta-slim.outputs.labels }}
89114

90115
- name: Publish package on PyPi
91116
run: |

.github/workflows/test.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@ on:
77
- "pyproject.toml"
88
- "poetry.lock"
99
- "Makefile"
10+
- ".github/workflows/test.yml"
1011

1112
jobs:
1213
test:
1314
name: Test
14-
runs-on: ubuntu-latest
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
arch: amd64
21+
- os: macos-latest
22+
arch: amd64
23+
- os: ubuntu-latest
24+
arch: arm64
25+
- os: macos-latest
26+
arch: arm64
1527
steps:
1628
- name: Check out the repo
1729
uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog],
66
and this project adheres to [Semantic Versioning].
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- ci: Introduced official MacOS support.
13+
- ci: Build `arm64` images for M1/M2 silicon.
14+
- ci: Build `-slim` images based on Alpine Linux.
15+
816
## [6.0.1] - 2022-08-19
917

1018
### Fixed

Dockerfile

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
11
# syntax=docker/dockerfile:1.3-labs
2-
FROM python:3.10-slim-buster
2+
FROM python:3.10-slim-buster AS compile-image
3+
ARG PYTEZOS=0
4+
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
5+
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
36

4-
ARG EXTRAS
5-
6-
SHELL ["/bin/bash", "-x", "-v", "-c"]
77
RUN <<eot
88
apt update
9-
apt install -y --no-install-recommends make git sudo `if [[ $EXTRAS =~ "pytezos" ]]; then echo build-essential pkg-config libsodium-dev libsecp256k1-dev libgmp-dev; fi`
9+
apt install -y gcc make git `if [[ $PYTEZOS = "1" ]]; then echo build-essential pkg-config libsodium-dev libsecp256k1-dev libgmp-dev; fi`
10+
1011
pip install --no-cache-dir poetry
11-
useradd -ms /bin/bash dipdup
12-
mkdir /home/dipdup/source
13-
rm -r /var/lib/apt/lists/* /var/log/*
12+
13+
mkdir -p /opt/dipdup
14+
15+
rm -r /var/log/* /var/lib/apt/lists/* /var/cache/* /var/lib/dpkg/status*
1416
eot
1517

16-
COPY --chown=dipdup Makefile pyproject.toml poetry.lock README.md /home/dipdup/source/
17-
COPY --chown=dipdup inject_pyproject.sh /usr/bin/inject_pyproject.sh
18-
WORKDIR /home/dipdup/source
18+
WORKDIR /opt/dipdup
19+
ENV PATH="/opt/dipdup/.venv/bin:$PATH"
20+
21+
COPY --chown=dipdup Makefile pyproject.toml poetry.lock README.md /opt/dipdup/
1922

2023
RUN <<eot
2124
# We want to copy our code at the last layer but not to break poetry's "packages" section
22-
mkdir -p /home/dipdup/source/src/dipdup
23-
touch /home/dipdup/source/src/dipdup/__init__.py
24-
poetry config virtualenvs.create false
25-
make install DEV=0 EXTRAS="${EXTRAS}"
26-
echo 'sudo /usr/bin/inject_pyproject.sh' >> /usr/bin/inject_pyproject
27-
echo 'dipdup ALL = NOPASSWD: /usr/bin/inject_pyproject.sh' >> /etc/sudoers
28-
chmod +x /usr/bin/inject_pyproject.sh
29-
chmod +x /usr/bin/inject_pyproject
30-
rm -r /root/.cache
25+
mkdir -p /opt/dipdup/src/dipdup
26+
touch /opt/dipdup/src/dipdup/__init__.py
27+
28+
make install DEV=0 PYTEZOS="${PYTEZOS}"
29+
30+
rm -r /root/.cache/
3131
eot
3232

33-
COPY --chown=dipdup . /home/dipdup/source
33+
FROM python:3.10-slim-buster AS build-image
34+
ARG PYTEZOS=0
35+
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
36+
SHELL ["/bin/bash", "-c"]
3437

35-
USER dipdup
36-
RUN poetry config virtualenvs.create false
38+
RUN <<eot
39+
useradd -ms /bin/bash dipdup
40+
pip install --no-cache-dir poetry
41+
42+
apt update
43+
apt install -y --no-install-recommends git `if [[ $PYTEZOS = "1" ]]; then echo libsodium-dev libsecp256k1-dev libgmp-dev; fi`
3744

45+
rm -r /var/log/* /var/lib/apt/lists/* /var/cache/* /var/lib/dpkg/status*
46+
eot
47+
48+
USER dipdup
49+
ENV PATH="/opt/dipdup/.venv/bin:$PATH"
50+
ENV PYTHONPATH="/home/dipdup:/home/dipdup/src:/opt/dipdup/src:/opt/dipdup/lib/python3.10/site-packages:$PYTHONPATH"
3851
WORKDIR /home/dipdup/
3952
ENTRYPOINT ["dipdup"]
4053
CMD ["run"]
54+
55+
COPY --chown=dipdup --chmod=0755 install_dependencies.sh /opt/dipdup/.venv/bin/install_dependencies
56+
COPY --chown=dipdup --chmod=0755 install_dependencies.sh /opt/dipdup/.venv/bin/inject_pyproject
57+
COPY --chown=dipdup --from=compile-image /opt/dipdup /opt/dipdup
58+
COPY --chown=dipdup . /opt/dipdup

0 commit comments

Comments
 (0)