Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: added old WIP Dockerfile and dockerignore #776

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**/*.pyc
**/.*cache
**/.cov
**/coverage

**/*.zip
**/*.db*

**/tags
**/dist
**/build
**/node_modules

other

aw-server/aw_server/static
!aw-server/aw_server/static/logo.png
aw-server-rust/target
aw-server-rust/NDK
89 changes: 89 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# This Dockerfile is used to build ActivityWatch in a Docker container.
#
# It lets us to build ActivityWatch on any platform that supports Docker,
# it also provides a way to build arm64 releases (not possible with GitHub Actions).

# TODO: Clean up this Dockerfile, it's a mess
# TODO: make use of multi-stage builds
# TODO: Avoid building aw-webui twice
# TODO: Fix aw-server-rust rebuilding in last step
FROM ubuntu:22.10

ARG PORT
ENV SERVER_PORT=$PORT

# Disables pip caching
ENV PIP_NO_CACHE_DIR=false

# Install dependencies
RUN apt-get update
RUN apt-get install -y python3 python3-distutils python3-pip python3-pyqt6 git build-essential apt-utils wget libfreetype6 libpng-dev libopenblas-dev gcc gfortran curl sudo zip

# Add `python` alias for `python3`
RUN ln -s /usr/bin/python3 /usr/bin/python

# Add nodejs repo
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
RUN apt-get install -y nodejs

# Install rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
ENV PATH="/root/.cargo/bin:$PATH"
RUN rustup toolchain install nightly --allow-downgrade --profile minimal

# Set up poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="/root/.local/bin:$PATH"
RUN poetry config virtualenvs.create false

# Create build directory
RUN mkdir /app
WORKDIR /app

# Install dependencies seperately, to utilize caching
RUN mkdir /app/aw-core
COPY aw-core/poetry.lock aw-core/pyproject.toml /app/aw-core
WORKDIR /app/aw-core
RUN poetry install --no-root && rm -rf ~/.cache/pypoetry/{cache,artifacts}

RUN mkdir /app/aw-server
COPY aw-server/poetry.lock aw-server/pyproject.toml /app/aw-server
WORKDIR /app/aw-server
RUN poetry install --no-root && rm -rf ~/.cache/pypoetry/{cache,artifacts}

# Set wether to build in release mode or not
ENV RELEASE=false

RUN mkdir /app/aw-server-rust
COPY aw-server-rust/. /app/aw-server-rust
WORKDIR /app/aw-server-rust
RUN --mount=type=cache,target=/app/aw-server-rust/target \
make build SKIP_WEBUI=true

# Build the webui
#RUN mkdir /app/aw-server/aw-webui
#COPY aw-server/aw-webui/. /app/aw-server/aw-webui
#WORKDIR /app/aw-server/aw-webui
#RUN --mount=type=cache,target=/root/.npm \
# make build

# Build the rest
WORKDIR /app
COPY . /app

#RUN make build SKIP_WEBUI=true

RUN poetry install --no-root
# NOTE: we have to skip aw-qt because there's no arm64 wheel for pyqt6 on PyPI
RUN --mount=type=cache,target=/app/aw-server-rust/target \
--mount=type=cache,target=/root/.npm \
make build SKIP_QT=true
RUN --mount=type=cache,target=/app/aw-server-rust/target \
make package SKIP_QT=true

# Cleanup
RUN rm -rf ~/.cache/pypoetry/{cache,artifacts}
RUN rm -rf /app/aw-server-rust/target

# Entrypoint
ENTRYPOINT ["/bin/sh", "-c"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ else
echo 'Rust not found, skipping aw-server-rust!'; \
fi
endif
ifeq ($(SKIP_QT),true)
@echo "Skipping aw-qt build"
else
make --directory=aw-qt build
endif
# The below is needed due to: https://github.com/ActivityWatch/activitywatch/issues/173
make --directory=aw-client build
make --directory=aw-core build
Expand Down Expand Up @@ -167,8 +171,12 @@ else
mkdir -p dist/activitywatch/aw-server-rust
cp -r aw-server-rust/target/package/* dist/activitywatch/aw-server-rust
endif
ifeq ($(SKIP_QT),true)
@echo "Skipping aw-qt package"
else
make --directory=aw-qt package
cp -r aw-qt/dist/aw-qt/. dist/activitywatch
endif
# Remove problem-causing binaries
rm -f dist/activitywatch/libdrm.so.2 # see: https://github.com/ActivityWatch/activitywatch/issues/161
rm -f dist/activitywatch/libharfbuzz.so.0 # see: https://github.com/ActivityWatch/activitywatch/issues/660#issuecomment-959889230
Expand Down