From 06cfa28b62b1e818f6660af46f59002064b8af85 Mon Sep 17 00:00:00 2001 From: Hayden Date: Tue, 19 Jan 2021 18:38:13 -0900 Subject: [PATCH] docker-file shrink --- .github/workflows/dockerbuild.alpine.yml | 49 ++++++++++++++++++ Dockerfile | 66 ++++++++++++++++++------ dev/scripts/buildx.sh | 1 + docker-compose.yml | 3 +- 4 files changed, 102 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/dockerbuild.alpine.yml create mode 100644 dev/scripts/buildx.sh diff --git a/.github/workflows/dockerbuild.alpine.yml b/.github/workflows/dockerbuild.alpine.yml new file mode 100644 index 000000000..82e8af31d --- /dev/null +++ b/.github/workflows/dockerbuild.alpine.yml @@ -0,0 +1,49 @@ +name: Docker Build Alpine + +on: + push: + branches: + - new-tests + +jobs: + build: + runs-on: ubuntu-latest + steps: + # + # Checkout + # + - name: checkout code + uses: actions/checkout@v2 + # + # Setup QEMU + # + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + # + # Setup Buildx + # + - name: install buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + # + # Login to Docker Hub + # + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # + # Build + # + - name: build the image + run: | + docker build --push \ + --tag hkotel/mealie:alpine \ + --platform linux/amd64,linux/arm/v7,linux/arm64 . diff --git a/Dockerfile b/Dockerfile index dd4b51eb9..bf8761a4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,28 +5,64 @@ RUN npm install COPY ./frontend/ . RUN npm run build -# FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim -FROM mrnr91/uvicorn-gunicorn-fastapi:python3.8 - +FROM python:3.8-alpine +RUN apk add --no-cache git curl libxml2-dev libxslt-dev libxml2 +ENV ENV prod +EXPOSE 80 WORKDIR /app -RUN apt-get update -y && \ - apt-get install -y python-pip python-dev git curl python3-dev libxml2-dev libxslt1-dev zlib1g-dev --no-install-recommends && \ - rm -rf /var/lib/apt/lists/* && \ - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ - cd /usr/local/bin && \ - ln -s /opt/poetry/bin/poetry && \ - poetry config virtualenvs.create false - COPY ./pyproject.toml /app/ +RUN apk add --update --no-cache --virtual .build-deps \ + g++ \ + py-lxml \ + python3-dev \ + musl-dev \ + gcc \ + build-base && \ + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false && \ + cd /app/ && poetry install --no-root --no-dev && \ + apk --purge del .build-deps + + COPY ./mealie /app -RUN poetry install --no-root --no-dev COPY --from=build-stage /app/dist /app/dist RUN rm -rf /app/test /app/.temp -ENV ENV prod -ENV APP_MODULE "app:app" -VOLUME [ "/app/data" ] + +CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "80"] + +# ---------------------------------- # +# Old Docker File +# ---------------------------------- # + +# FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim +# FROM mrnr91/uvicorn-gunicorn-fastapi:python3.8 + + +# WORKDIR /app + +# RUN apt-get update -y && \ +# apt-get install -y python-pip python-dev git curl python3-dev libxml2-dev libxslt1-dev zlib1g-dev --no-install-recommends && \ +# rm -rf /var/lib/apt/lists/* && \ +# curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ +# cd /usr/local/bin && \ +# ln -s /opt/poetry/bin/poetry && \ +# poetry config virtualenvs.create false + +# COPY ./pyproject.toml /app/ + +# COPY ./mealie /app +# RUN poetry install --no-root --no-dev +# COPY --from=build-stage /app/dist /app/dist +# RUN rm -rf /app/test /app/.temp + +# ENV ENV prod +# ENV APP_MODULE "app:app" + +# VOLUME [ "/app/data" ] diff --git a/dev/scripts/buildx.sh b/dev/scripts/buildx.sh new file mode 100644 index 000000000..37ad4dcd5 --- /dev/null +++ b/dev/scripts/buildx.sh @@ -0,0 +1 @@ +docker buildx build . \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c8363c44f..22f78041d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,8 +9,7 @@ services: ports: - 9090:80 environment: - db_type: sql + db_type: sqlite # volumes: # - ./mealie/data/:/app/data -