From 37e03183d8794dde4d043b8897e29e2362e3651d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 3 Jul 2024 23:33:52 +0530 Subject: [PATCH 1/2] fix: install TW on docker from source and download dependencies --- backend/Dockerfile | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index ceb28611..584b466e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -14,19 +14,30 @@ COPY . . # Copy the .env file COPY .env .env -# Install dependencies for Taskwarrior and libuuid-dev -RUN apk add --no-cache cmake g++ make tar util-linux-dev rust cargo libuuid libstdc++ -RUN apk update -RUN apk add util-linux -RUN apk add libgcc -RUN apk add libstdc++ -RUN apk add libgc++ -RUN apk add libuuid - -# Copy Taskwarrior source code and build it -COPY task-3.0.2.tar.gz /tmp/task-3.0.2.tar.gz -RUN tar xzf /tmp/task-3.0.2.tar.gz && \ - cd task-3.0.2 && \ +# Install dependencies for Taskwarrior and libuuid +RUN apk add --no-cache \ + cmake \ + g++ \ + make \ + tar \ + util-linux-dev \ + rust \ + cargo \ + libuuid \ + libstdc++ \ + libgcc \ + # Ensure all required packages are installed + && apk update \ + && apk add --no-cache \ + libuuid \ + libstdc++ \ + libgcc \ + util-linux + +# Download and build Taskwarrior +RUN wget https://github.com/GothenburgBitFactory/taskwarrior/releases/download/v3.0.2/task-3.0.2.tar.gz -O /tmp/task-3.0.2.tar.gz && \ + tar xzf /tmp/task-3.0.2.tar.gz -C /tmp && \ + cd /tmp/task-3.0.2 && \ cmake -DCMAKE_BUILD_TYPE=release . && \ make && \ make install @@ -34,10 +45,16 @@ RUN tar xzf /tmp/task-3.0.2.tar.gz && \ # Build the Go application RUN go build -o main . -# Use a minimal image for running the backend (Can use others as well) +# Use a minimal image for running the backend FROM alpine:latest WORKDIR /root/ +# Install runtime dependencies +RUN apk add --no-cache \ + libuuid \ + libstdc++ \ + libgcc + # Copy the binary and .env file from the build stage COPY --from=build /app/main . COPY --from=build /app/.env . From b797e29c7de627373da5a9dd433e6e4a68ad9492 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 3 Jul 2024 23:34:35 +0530 Subject: [PATCH 2/2] fix: add healthcheck --- docker-compose.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f3597e86..874c1054 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,15 @@ services: - "80:80" networks: - tasknetwork + depends_on: + - backend + env_file: + - ./frontend/.env + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:80"] + interval: 30s + timeout: 10s + retries: 3 backend: build: @@ -18,14 +27,27 @@ services: - tasknetwork depends_on: - syncserver + env_file: + - ./backend/.env + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/health"] + interval: 30s + timeout: 10s + retries: 3 + volumes: + - ./backend/data:/app/data syncserver: - # THIS IMAGE SHOULD BE PULLED FROM THE OFFICIAL TASKCHAMPION-SYNC-SERVER REPOSITORY image: taskchampion-sync-server:latest ports: - "8080:8080" networks: - tasknetwork + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 30s + timeout: 10s + retries: 3 networks: tasknetwork: