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

feat: add docker configuration for the site #11

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
task-3.0.2
48 changes: 48 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Use the official Golang image for building the backend
FROM golang:1.22-alpine as build

# Set working directory
WORKDIR /app

# Copy go.mod and go.sum files
COPY go.mod go.sum ./
RUN go mod tidy

# Copy the rest of the application code
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++

# 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 && \
cmake -DCMAKE_BUILD_TYPE=release . && \
make && \
make install

# Build the Go application
RUN go build -o main .

# Use a minimal image for running the backend (Can use others as well)
FROM alpine:latest
WORKDIR /root/

# Copy the binary and .env file from the build stage
COPY --from=build /app/main .
COPY --from=build /app/.env .
COPY --from=build /usr/local/bin/task /usr/local/bin/task

# Expose port 8000
EXPOSE 8000

# Command to run the executable
CMD ["./main"]
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "80:80"
networks:
- tasknetwork

backend:
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "8000:8000"
networks:
- tasknetwork
depends_on:
- syncserver

syncserver:
# THIS IMAGE SHOULD BE PULLED FROM THE OFFICIAL TASKCHAMPION-SYNC-SERVER REPOSITORY
image: taskchampion-sync-server:latest
ports:
- "8080:8080"
networks:
- tasknetwork

networks:
tasknetwork:
driver: bridge
26 changes: 26 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use node image for building the frontend
FROM node:16-alpine as build

# Set working directory
WORKDIR /app

# Copy package.json and install dependencies
COPY package.json package-lock.json ./
RUN npm install

# Copy the rest of the application code and build
COPY . .
RUN npm run build

# Serve the frontend using nginx
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html

# Copy nginx configuration file
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

# Start nginx
CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;

location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
}
}
34 changes: 34 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"date-fns": "^3.6.0",
"firebase": "^10.12.2",
"lucide-react": "^0.294.0",
"react": "^18.2.0",
Expand Down