Skip to content

Commit

Permalink
chore: test docker-compose on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
resolritter committed Apr 6, 2023
1 parent f22f356 commit b4b69ed
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 23 deletions.
5 changes: 1 addition & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
frontend/appflowy_flutter/
frontend/scripts/
frontend/rust-lib/target
shared-lib/target/
.git
47 changes: 47 additions & 0 deletions .github/workflows/docker_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Docker-CI

on:
push:
branches:
- main
- release/*
paths:
- frontend/**

pull_request:
branches:
- main
- release/*
paths:
- frontend/**
types:
- opened
- synchronize
- reopened
- unlocked
- ready_for_review

jobs:
build-app:
if: github.event.pull_request.draft != true
concurrency:
group: docker_ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Build the app
shell: bash
run: |
set -eu -o pipefail
cd frontend/scripts/docker-buildfiles
docker-compose build --no-cache --progress=plain \
| while read line; do \
if [[ "$line" =~ ^Step[[:space:]] ]]; then \
echo "$(date -u '+%H:%M:%S') | $line"; \
else \
echo "$line"; \
fi; \
done \
36 changes: 23 additions & 13 deletions frontend/scripts/docker-buildfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ USER $user
WORKDIR /home/$user

# Install yay
RUN sudo pacman -S --needed --noconfirm git
RUN git clone --depth 1 https://aur.archlinux.org/yay.git && \
cd yay && \
makepkg -sri --needed --noconfirm
RUN sudo pacman -S --needed --noconfirm curl tar
RUN curl -sSfL \
--output yay.tar.gz \
https://github.com/Jguer/yay/releases/download/v12.0.2/yay_12.0.2_x86_64.tar.gz && \
tar -xf yay.tar.gz && \
sudo mv yay_12.0.2_x86_64/yay /bin && \
rm -rf yay_12.0.2_x86_64 && \
yay --version

# Install Rust
RUN yay -S --noconfirm curl base-devel openssl clang cmake ninja pkg-config xdg-user-dirs
Expand All @@ -31,22 +35,26 @@ RUN source ~/.cargo/env && \
rustup default stable

# Install Flutter
RUN sudo pacman -S --noconfirm tar gtk3
RUN sudo pacman -S --noconfirm git tar gtk3
RUN curl -sSfL \
--output flutter.tar.xz \
https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.3.10-stable.tar.xz && \
https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.7.5-stable.tar.xz && \
tar -xf flutter.tar.xz && \
rm flutter.tar.xz
RUN flutter config --enable-linux-desktop
RUN flutter doctor
RUN dart pub global activate protoc_plugin

# Build the AppFlowy app
RUN sudo pacman -S --noconfirm libkeybinder3 sqlite
RUN git clone --depth 1 https://github.com/AppFlowy-IO/appflowy.git
RUN cd appflowy/frontend && \
# Intall build dependencies for AppFlowy
RUN sudo pacman -S --noconfirm git libkeybinder3 sqlite
RUN source ~/.cargo/env && cargo install --force cargo-make duckscript_cli

# Build AppFlowy
COPY . /appflowy
RUN sudo chown -R $user: /appflowy
WORKDIR /appflowy
RUN cd frontend && \
source ~/.cargo/env && \
cargo install --force cargo-make duckscript_cli && \
cargo make appflowy-flutter-deps-tools && \
cargo make -p production-linux-x86_64 appflowy-linux

Expand Down Expand Up @@ -74,7 +82,9 @@ USER $user

# Set up the AppFlowy app
WORKDIR /home/$user
COPY --from=builder /home/makepkg/appflowy/frontend/appflowy_flutter/build/linux/x64/release/bundle .
RUN xdg-user-dirs-update
COPY --from=builder /appflowy/frontend/appflowy_flutter/build/linux/x64/release/bundle .
RUN xdg-user-dirs-update && \
test -e ./AppFlowy && \
file ./AppFlowy

CMD ["./AppFlowy"]
9 changes: 3 additions & 6 deletions frontend/scripts/docker-buildfiles/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ version: "3"

services:
app:
build: .
build:
context: ../../..
dockerfile: ./frontend/scripts/docker-buildfiles/Dockerfile
image: appflowy/appflowy:latest
stdin_open: true
# tty: true
Expand All @@ -22,9 +24,4 @@ services:
- /tmp/.X11-unix:/tmp/.X11-unix
- /dev/dri:/dev/dri
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
- builder-data:/home/makepkg
- /etc/pacman.d/mirrorlist:/etc/pacman.d/mirrorlist
network_mode: host

volumes:
builder-data: # Used to cache build artifacts and thus speed up image rebuilds

0 comments on commit b4b69ed

Please sign in to comment.