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

🚀 Feature Request: A docker-compose file to deploy this amazing project with ease #118

Open
gambit-dross opened this issue Oct 21, 2024 · 5 comments

Comments

@gambit-dross
Copy link

No description provided.

@ppfeister
Copy link

Not being available on Dockerhub or ghcr is the only thing holding me back from even trying it self hosted --- would be great to see

@athamour1
Copy link

Hey, I can help with this feature !
Contact me to start with the docker implementation

@athamour1
Copy link

Upon further inspection it should be straight forward to add the docker implementation with the following files

This is for the backend

# Stage 1: Build the Go server
FROM golang:1.20-alpine AS build

# Set working directory
WORKDIR /app

# Copy the Go module files and download dependencies
COPY server/go.mod server/go.sum ./
RUN go mod download

# Copy the rest of the server source code
COPY server/ .

# Build the Go server for Linux
RUN GOOS=linux GOARCH=amd64 go build -o server -buildvcs=false

# Stage 2: Run the server with a minimal image
FROM alpine:latest

# Set working directory
WORKDIR /app

# Copy the server binary from the build stage
COPY --from=build /app/server .

# Expose the port your server runs on (adjust if needed)
EXPOSE 8080

# Start the server
CMD ["./server", "-release=true"]

This is for the frontend

# Stage 1: Build the frontend
FROM node:18-alpine AS build

# Set working directory
WORKDIR /app

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

# Copy the frontend source code
COPY frontend/ .

# Build the frontend
RUN npm run build

# Stage 2: Serve the frontend with Nginx
FROM nginx:alpine

# Define where Nginx will serve the files from
COPY --from=build /app/dist /usr/share/nginx/html

# Expose the default port used by Nginx
EXPOSE 80

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]

And this is to orchestrate the deployment, i also added the mongo db service, if it needs anything else to run, it can be added here.

services:
  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend  # Use Dockerfile.frontend for the frontend build
    ports:
      - "80:80"  # Map port 80 of the container to port 80 on the host
    # env_file:
    #   - ./frontend/.env  # Path to the frontend .env file
    networks:
      - app-network

  backend:
    build:
      context: .
      dockerfile: Dockerfile.backend  # Use Dockerfile.backend for the backend build
    ports:
      - "8080:8080"  # Map port 8080 of the container to port 8080 on the host
    # env_file:
    #  - ./server/.env  # Path to the backend .env file
    environment:
      - MONGO_URI=mongodb://mongo:27017/your_database_name  # MongoDB URI for backend connection
    networks:
      - app-network
    depends_on:
      - mongo  # Ensure MongoDB starts before backend
    restart: always

  mongo:
    image: mongo:6.0  # MongoDB image
    container_name: mongo  # Container name for easy reference
    ports:
      - "27017:27017"  # Expose MongoDB's default port
    networks:
      - app-network
    volumes:
      - mongo_data:/data/db  # Persist MongoDB data on a Docker volume

networks:
  app-network:
    driver: bridge

volumes:
  mongo_data:

The only problem I found is with some ENV vars, like mongo db URL, it should be set by an env var to route it to the correct container.

@avatar1024
Copy link

avatar1024 commented Nov 21, 2024

Indeed would be wonderful to have a docker compose file! I have made a request on the Cloudron forum to deploy this app once there is Docker for it.

@gambit-dross
Copy link
Author

@mariushosting This seems like a great self hosted app, any idea how this compose file should change for this to work with Synology+Portainer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants