Skip to content

Commit cdf8dbb

Browse files
Docker: base image improvements, package deployment codegen (#88)
1 parent 2566cc1 commit cdf8dbb

Some content is hidden

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

51 files changed

+2338
-146
lines changed

.dockerignore

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
dist/
2-
docs/
3-
examples/
4-
assets/
5-
.pytest_cache
6-
.ipynb_checkpoints
7-
*.egg-info
8-
scripts
9-
tests
10-
*.ipynb
11-
*.json
12-
*.zip
13-
docker-compose.yml
14-
Dockerfile
1+
*
2+
3+
!Makefile
4+
!pyproject.toml
5+
!poetry.lock
6+
!README.md
7+
!src/**
8+
!inject_pyproject.sh
9+
10+
__pycache__
11+
*.pyc
12+
*.pyo
13+
*.pyd

Dockerfile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
FROM python:3.8-slim-buster
22

3+
ARG PLUGINS
4+
5+
SHELL ["/bin/bash", "-x", "-v", "-c"]
36
RUN apt update && \
4-
apt install -y make git && \
7+
apt install -y make git sudo `if [[ $PLUGINS =~ "pytezos" ]]; then echo build-essential pkg-config libsodium-dev libsecp256k1-dev libgmp-dev; fi` && \
58
rm -rf /var/lib/apt/lists/*
69
RUN pip install poetry
710
RUN useradd -ms /bin/bash dipdup
811

912
RUN mkdir /home/dipdup/source
10-
COPY Makefile pyproject.toml poetry.lock README.md /home/dipdup/source/
13+
COPY --chown=dipdup Makefile pyproject.toml poetry.lock README.md /home/dipdup/source/
1114
# We want to copy our code at the last layer but not to break poetry's "packages" section
1215
RUN mkdir -p /home/dipdup/source/src/dipdup && \
1316
touch /home/dipdup/source/src/dipdup/__init__.py
1417

1518
WORKDIR /home/dipdup/source
1619
RUN poetry config virtualenvs.create false
17-
RUN make install DEV=0
20+
RUN make install DEV=0 PLUGINS="${PLUGINS}"
21+
22+
COPY --chown=dipdup inject_pyproject.sh /home/dipdup/inject_pyproject
23+
RUN chmod +x /home/dipdup/inject_pyproject
24+
RUN echo 'dipdup ALL = NOPASSWD: /home/dipdup/inject_pyproject' >> /etc/sudoers
1825

19-
COPY . /home/dipdup/source/
20-
RUN chown -R dipdup /home/dipdup/
26+
COPY --chown=dipdup src /home/dipdup/source/src
2127

2228
USER dipdup
29+
RUN poetry config virtualenvs.create false
2330

2431
WORKDIR /home/dipdup/
25-
EXPOSE 8888
26-
ENTRYPOINT ["python", "-m", "dipdup"]
27-
CMD ["-c", "dipdup.yml", "run"]
32+
ENTRYPOINT ["dipdup"]
33+
CMD ["run"]

Dockerfile.pytezos

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Temporary copy for dockerhub
2+
FROM python:3.8-slim-buster
3+
4+
ARG PLUGINS=pytezos
5+
6+
SHELL ["/bin/bash", "-x", "-v", "-c"]
7+
RUN apt update && \
8+
apt install -y make git sudo `if [[ $PLUGINS =~ "pytezos" ]]; then echo build-essential pkg-config libsodium-dev libsecp256k1-dev libgmp-dev; fi` && \
9+
rm -rf /var/lib/apt/lists/*
10+
RUN pip install poetry
11+
RUN useradd -ms /bin/bash dipdup
12+
13+
RUN mkdir /home/dipdup/source
14+
COPY --chown=dipdup Makefile pyproject.toml poetry.lock README.md /home/dipdup/source/
15+
# We want to copy our code at the last layer but not to break poetry's "packages" section
16+
RUN mkdir -p /home/dipdup/source/src/dipdup && \
17+
touch /home/dipdup/source/src/dipdup/__init__.py
18+
19+
WORKDIR /home/dipdup/source
20+
RUN poetry config virtualenvs.create false
21+
RUN make install DEV=0 PLUGINS="${PLUGINS}"
22+
23+
COPY --chown=dipdup inject_pyproject.sh /home/dipdup/inject_pyproject
24+
RUN chmod +x /home/dipdup/inject_pyproject
25+
RUN echo 'dipdup ALL = NOPASSWD: /home/dipdup/inject_pyproject' >> /etc/sudoers
26+
27+
COPY --chown=dipdup src /home/dipdup/source/src
28+
29+
USER dipdup
30+
RUN poetry config virtualenvs.create false
31+
32+
WORKDIR /home/dipdup/
33+
ENTRYPOINT ["dipdup"]
34+
CMD ["run"]

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
.PHONY: docs
33
.DEFAULT_GOAL: all
44

5-
DEV ?= 1
5+
DEV=1
6+
PLUGINS=""
7+
TAG=latest
68

79
all: install lint test cover
810
lint: isort black flake mypy
@@ -11,7 +13,9 @@ debug:
1113
pip install . --force --no-deps
1214

1315
install:
14-
poetry install `if [ "${DEV}" = "0" ]; then echo "--no-dev"; fi`
16+
poetry install \
17+
`if [ -n "${PLUGINS}" ]; then for i in ${PLUGINS}; do echo "-E $$i "; done; fi` \
18+
`if [ "${DEV}" = "0" ]; then echo "--no-dev"; fi`
1519

1620
isort:
1721
poetry run isort src tests
@@ -35,7 +39,8 @@ build:
3539
poetry build
3640

3741
image:
38-
docker build . -t dipdup
42+
docker build . -t dipdup:${TAG}
43+
docker build . -t dipdup:${TAG}-pytezos --build-arg PLUGINS=pytezos
3944

4045
release-patch:
4146
bumpversion patch

docker-compose.yml

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

inject_pyproject.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#$/bin/bash
2+
if test -f "/home/dipdup/pyproject.toml"; then
3+
cd /home/dipdup/
4+
sed -i -e 's/dipdup = .*/dipdup = {path = "\/home\/dipdup\/source", develop = true}/' pyproject.toml
5+
poetry install --no-dev
6+
fi

0 commit comments

Comments
 (0)