Commit Graph

228 Commits

Author SHA1 Message Date
Vadim 2261346334
DockerHub-README.md: reword ambiguous command (#6080)
* DockerHub-README.md: reword ambiguous command

Being unfamiliar with the docker options, I thought the square brackets could be part of the command.

Instead, they refer to the sentence *after* the command, that is, they meant "optionally".

To remove the ambiguity, I put into onto different lines with an explanation.

* DockerHub-README.md: reword again, -v by default

- only leave the command with -v as an example
- grammar
- httpS link
2023-04-27 08:49:15 +00:00
Maximilian Hils c38c01fa4f
Switch to pyproject.toml (#6016)
* switch to pyproject.toml

* fix mypy

* fix pyinstaller
2023-03-26 17:40:32 +00:00
autofix-ci[bot] 51670861e6 [autofix.ci] apply automated fixes 2023-02-27 08:37:11 +01:00
Maksym Medvied 5969f25db4
pass signals to mitmproxy in docker-entrypoint.sh (#5920)
Current docker-entrypoint.sh [0][1] runs

    gosu mitmproxy "$@"

for mitmproxy, mitmdump and mitmweb. There is a problem with this
approach: bash becomes a parent process for mitmproxy [2][3], but when
signals are sent by docker-compose to mitmproxy container they are sent
to bash, but they are not delivered to mitmproxy [4]. This leads to a
slow shutdown of the container, because by default docker sends SIGTERM,
waits for 10 seconds and then sends SIGKILL if the container is still
alive [5].

This patch solves the issue by replacing bash process with mitmproxy
entirely using "exec" - this way the signals are delivered to mitmproxy
directly.

To test the patch a Dockerfile [6] that applies the patch to the release
image from the dockerhub could be used along with slighly modified
compose.yml [7]. With the patch bash is no longer running inside the
container [8] and the `docker compose down` time on my machine drops
from 10.3s to 0.5s [9].

0. https://github.com/mitmproxy/mitmproxy/blob/main/release/docker/docker-entrypoint.sh
1. To confirm that this is what's actually in the image:
    ```
    > docker run mitmproxy/mitmproxy grep gosu /usr/local/bin/docker-entrypoint.sh
      gosu mitmproxy "$@"
    ```
2. compose.yaml
    ```
    services:
      mitmproxy-test:
        image: mitmproxy/mitmproxy
        command: ["mitmweb"]
        # https://github.com/mitmproxy/mitmproxy/issues/5727
        stdin_open: true
        tty: true
    ```
3. We can see that the parent PID for mitmweb is the pid of bash.
    ```
    > docker compose up -d
    [+] Running 2/2
     ⠿ Network mitmproxy_default             Created           0.1s
     ⠿ Container mitmproxy-mitmproxy-test-1  Started           0.5s
    > docker compose top
    mitmproxy-mitmproxy-test-1
    UID    PID     PPID    C    STIME   TTY     TIME       CMD
    root   31227   31202   0    16:12   pts/0   00:00:00   /bin/bash /usr/local/bin/docker-entrypoint.sh mitmweb
    root   31314   31227   1    16:12   pts/0   00:00:01   /usr/local/bin/python /usr/local/bin/mitmweb
    ```
4. https://unix.stackexchange.com/a/196053
5. https://docs.docker.com/compose/faq/#why-do-my-services-take-10-seconds-to-recreate-or-stop
6. Dockerfile:
    ```
    FROM mitmproxy/mitmproxy

    RUN sed -i 's/^  gosu mitmproxy/  exec gosu mitmproxy/' /usr/local/bin/docker-entrypoint.sh
    ```
7. compose.yaml to build an image from Dockerfile and use it:
    ```
    services:
      mitmproxy-test:
        build:
          dockerfile: Dockerfile
          context: .
        command: ["mitmweb"]
        # https://github.com/mitmproxy/mitmproxy/issues/5727
        stdin_open: true
        tty: true
    ```
8. With the patch:
    ```
    > docker compose top
    mitmproxy-mitmproxy-test-1
    UID    PID    PPID   C    STIME   TTY     TIME       CMD
    root   4994   4970   50   17:00   pts/0   00:00:02   /usr/local/bin/python /usr/local/bin/mitmweb
     ```
9. Without the patch:
    ```
    > docker compose down
    [+] Running 2/2
     ⠿ Container mitmproxy-mitmproxy-test-1  Removed          10.2s
     ⠿ Network mitmproxy_default             Removed           0.1s
    ```
   With the patch:
    ```
    > docker compose down
    [+] Running 2/2
     ⠿ Container mitmproxy-mitmproxy-test-1  Removed           0.4s
     ⠿ Network mitmproxy_default             Removed           0.1s
    ```
2023-02-09 11:43:47 +01:00
autofix-ci[bot] 8c2428c9d3
[autofix.ci] apply automated fixes 2022-11-29 13:28:41 +00:00
Aldo Cortesi 0bbb0215c1
more mypy (#5724)
Co-authored-by: requires.io <support@requires.io>
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2022-11-13 18:04:34 +00:00
Maximilian Hils f8bd7516cc unbreak docker ci 2022-11-10 17:28:45 +01:00
Maximilian Hils 3b8e1f6e2a skip self-test for console ui 2022-11-10 13:23:10 +01:00
Maximilian Hils 0ad8630487 add self-test addon for binaries 2022-11-04 10:41:46 +00:00
Maximilian Hils 597eaf4148
properly assume Docker permissions, fix #5700 (#5702) 2022-10-31 18:16:00 +01:00
Maximilian Hils f3f9df9b63
fix filenames, test final Windows installer (#5691) 2022-10-29 15:11:54 +00:00
Maximilian Hils 34b0600ef8
fix windows installer build (#5690) 2022-10-29 14:12:16 +00:00
Maximilian Hils 36dcc2ca0e
ci: simplify release script (#5688) 2022-10-28 17:02:12 +02:00
Maximilian Hils 8a79f61790 ci: fixup release permissions 2022-10-28 14:39:57 +02:00
Maximilian Hils 420d7f1cea ci: add option to skip status checks for releases 2022-10-28 14:39:57 +02:00
Maximilian Hils b5302ab522
Upgrade to Python 3.11 (#5678)
* upgrade to Python 3.11

* compatibility fixes
2022-10-26 11:13:37 +00:00
Maximilian Hils 58863cfb62
add more release automation (#5674) 2022-10-24 17:06:40 +02:00
Maximilian Hils 839115df8e
separate snapshot and release deploy jobs (#5669) 2022-10-22 14:09:44 +02:00
Maximilian Hils 8023b22498
Docker: assume uid of who holds permissions (#5550)
* Docker: assume uid of who holds permissions

* add docs
2022-09-08 17:42:09 +00:00
Manuel Meitinger e11626395e
Fix running hook issue and signal proxyserver updates. (#5512)
* add startup hook

* remove StartupHook

* add instance state reports

* make server stop log entries clearer

* fix default param issue

* add SyncSignal and AsyncSignal

* fix signal issues

* simpler update handling

* fix coverage

* minor change to better reflect server update state

* fix reuse tests on linux/wsl

* exterminate `mitmproxy.exceptions.TypeError`

Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2022-08-14 00:11:01 +02:00
Maximilian Hils 5df703cc42 ci: don't build installers for PRs 2022-07-29 13:42:42 +02:00
Maximilian Hils f94951c52f fix msix builds 2022-07-28 16:16:24 +02:00
Maximilian Hils 01254fd424 revise display names 2022-07-25 14:38:21 +02:00
Maximilian Hils 7a4fdb70e8 app manifest: remove optional port declarations 2022-07-25 14:14:05 +02:00
Maximilian Hils 3872d33111 simplify ci build script, add MSIX installer and Microsoft store. 2022-07-25 01:22:57 +02:00
Maximilian Hils 8ffd2dcaaa windows installer: use 64bit builds 2022-06-28 14:18:40 +02:00
Maximilian Hils 87d3d1cb88 pyinstaller: move hooks into package 2022-06-28 14:18:40 +02:00
Maximilian Hils b3587b52b2 make it black! 2022-04-28 19:11:10 +02:00
Maximilian Hils b31ad66225 `autoflake --in-place **/*.py` 2022-04-26 13:52:46 +02:00
Maximilian Hils 9d1e3107e8 `pyupgrade --keep-runtime-typing --py38-plus` 2022-03-29 15:29:37 +02:00
Maximilian Hils 7352811eef bump to 8.0.0 2022-03-19 17:20:32 +01:00
Maximilian Hils 218c942808 docker: use Python 3.10 2022-03-19 15:38:30 +01:00
Christian Zenker eb43ae4709
Use the slim base image for container (#4889) 2021-11-16 12:49:12 +01:00
Thomas Kriechbaumer fffed0cb3a bump docker
closes #4846
2021-10-20 19:57:21 +02:00
Maximilian Hils 4229253a6e
bump installbuilder (#4800) 2021-09-13 15:02:15 +00:00
Maximilian Hils 10bf38e42f strip `v` from tags when uploading binaries 2021-07-19 13:02:04 +02:00
Maximilian Hils f1f86f9a74 docker: re-run buildx to push all architectures to `latest` tag 2021-07-19 13:02:04 +02:00
Maximilian Hils 7e9c487d6b update release instructions 2021-07-16 13:32:17 +02:00
Maximilian Hils 34a620e57b
Docker: Add aarch64 Images (#4637)
* feat(cibuild): add buildx multi arch builds

* chore: add changelog for arm64

* temporarily enable docker ci job for PRs

* Update cibuild.py

* Update cibuild.py

* chore(cibuild): create docker-container xbuilder

* chore(cibuild): fix lint

* temporarily remove run check to see error message

* Update cibuild.py

* Update cibuild.py

* Update cibuild.py

* Update main.yml

* Update main.yml

* Update main.yml

* Update cibuild.py

* Update cibuild.py

* Update Dockerfile

* cleanup #1

* next test

* move to test branch

* fixup

* now upload

* enable armv6/7

* use multi-stage build to reduce image size

* armv7?

* drop armv6/armv7

Co-authored-by: Niels Hofmans <hello@ironpeak.be>
2021-06-15 13:47:50 +00:00
Maximilian Hils 518fb94124
Harden CI Pipeline (#4590)
* ci: use actions/checkout@v2

* ci: always specify python version

* ci: pin external actions

* ci: split docs job, pin immediate dependencies

* ci: correct hugo sha256sum

* ci: full repo fetch depth for tests

* ci: use pip-tools to pin all the things

* ci: minor fixes

* ci: fixup

* ci: streamline pinned install

* ci: minor fixes

* ci: fix py3.8 pins

* ci: don't persist checkout credentials

* ci: always run local linter

* ci: test docs deployment from actions-hardening branch

* ci: fix docs job

* ci: pass in credentials

* ci: fix file permissions

* ci: try harder to fix docs deploy

* ci: fix docker artifact name

* Revert "ci: test docs deployment from actions-hardening branch"

This reverts commit 30cfb7a814.

* unpin PyPI dependencies

* ci: install tox first

* ci: fixups

* ci: fixups

* ci: fixups

* ci: fixups
2021-05-11 11:17:09 +02:00
Maximilian Hils 1b0fce6aba Revert "Copy examples into Docker image (#4447)"
This reverts commit a5ed1d377b.
2021-04-05 10:31:46 +02:00
Anatoli Babenia a5ed1d377b
Copy examples into Docker image (#4447) 2021-04-05 10:20:52 +02:00
Peter Dave Hello 66c8ecc71e
docker: avoid additional apt packages by `--no-install-recommends` (#4543)
This will help we keep the image not too heavy that caused by those
additional, suggestion apt packages.

Only install the packages we explicitly want.
2021-04-05 10:09:34 +02:00
Peter Dave Hello f1b55fc817
Fix typo: Github should be GitHub (#4541) 2021-04-05 10:08:21 +02:00
Maximilian Hils ead33008bc master branch -> main branch 2021-03-30 15:30:45 +02:00
Maximilian Hils e40bf0251d
docker: build from release dir to speed up context sending (#4498) 2021-03-12 07:45:21 +00:00
Peter Dave Hello 123342ea0b
Improve Markdown syntax(styling) (#4496)
* Improve Markdown syntax

- Add missing blank lines
- Remove trailing spaces
- Remove additional blank lines
- Fix indentation consistency and correctness

* Update addons-examples.md

Co-authored-by: Maximilian Hils <github@maximilianhils.com>
2021-03-11 19:13:02 +01:00
Peter Dave Hello 27ba85bc30
Switch Docker release to be based on Debian instead of Alpine (#4493) 2021-03-11 16:49:07 +01:00
Maximilian Hils ec9bc455c0 remove ci credential check
it turns out pull requests from trusted contributors do have access to secrets,
so we can't do that check. Checking for the repo only doesn't make much sense.
2021-01-05 22:00:54 +01:00
Maximilian Hils cca242a581 Windows: build pyinstaller onedir and use it for installer
This greatly improves startup time as pyinstaller doesn't have to
unpack everything on startup. The same also applies to macOS and Linux,
but there we 1) don't have installers to hide all the files and
2) have a filesystem that deals much better with lots of small files.

Additionally, simplify cibuild to be a bit more reasonable.
2021-01-05 15:56:33 +01:00