Skip to content

Commit

Permalink
feat: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
steveiliop56 committed Nov 27, 2024
1 parent f87fc18 commit 321178c
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DISCORD=your-discord-token
RUNTIPI=runtipi-server-url
JWT_SECRET=your-jwt-secret
APPSTORE=https://github.com/runtipi/runtipi-appstore
DATABASE_PATH=/data/tipicord.db
REFRESH=30
29 changes: 28 additions & 1 deletion .github/workflows/alpha-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- name: Get tag
id: tag
run: echo "name=$(cat internal/assets/version)-alpha.${{ github.event.inputs.alpha }}" >> $GITHUB_OUTPUT


build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,6 +45,34 @@ jobs:
name: tipicord-${{ matrix.os }}-${{ matrix.arch }}
path: tipicord-${{ matrix.os }}-${{ matrix.arch }}

build-docker:
needs: [get-tag, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/arm64, linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/tipicord:${{ needs.get-tag.outputs.tag }}

alpha-release:
needs: [get-tag, build]
runs-on: ubuntu-latest
Expand Down
29 changes: 28 additions & 1 deletion .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- name: Get tag
id: tag
run: echo "name=$(cat internal/assets/version)-beta.${{ github.event.inputs.alpha }}" >> $GITHUB_OUTPUT


build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,6 +45,34 @@ jobs:
name: tipicord-${{ matrix.os }}-${{ matrix.arch }}
path: tipicord-${{ matrix.os }}-${{ matrix.arch }}

build-docker:
needs: [get-tag, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/arm64, linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/tipicord:${{ needs.get-tag.outputs.tag }}

beta-release:
needs: [get-tag, build]
runs-on: ubuntu-latest
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,34 @@ jobs:
name: tipicord-${{ matrix.os }}-${{ matrix.arch }}
path: tipicord-${{ matrix.os }}-${{ matrix.arch }}

build-docker:
needs: [get-tag, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/arm64, linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/tipicord:${{ needs.get-tag.outputs.tag }}, ghcr.io/${{ github.repository_owner }}/tipicord:latest

release:
needs: [get-tag, build]
runs-on: ubuntu-latest
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ tipicord.db

# Build out
tipicord
tipicord.exe
tipicord.exe

# Env
.env

# Data
data
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --- BUILDER ----
FROM golang:1.23-alpine3.20 AS builder

WORKDIR /build

COPY go.mod go.mod
COPY go.sum go.sum
COPY main.go main.go
COPY internal/ internal/
COPY cmd/ cmd/

RUN go mod tidy

RUN go build -ldflags "-s -w" -o tipicord main.go

# --- RUNNER ----
FROM alpine:3.20 AS runner

WORKDIR /tipicord

RUN mkdir /data

COPY --from=builder /build/tipicord /tipicord

ENV DATABASE_PATH=/data/tipicord.db

ENTRYPOINT ["/tipicord/tipicord"]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ This project is still in early stages of development so it only includes the bas

## Getting started

Right now there are no available binaries but I am working on releasing both a docker image and a binary, but for now you will have to [build](#building-️) it yourself using Go.
You can run tipicord with two ways, docker or binary. If you chose binary, you can grab the latest binary from the [releases](https://github.com/steveiliop56/tipicord/releases) page, then `chmod +x tipicord` and finally you can run it with `./tipicord`. *assuming the binary is named tipicord*

Running with docker is also very easy, you just need to download the docker compose file from [here](./docker-compose.yml) and run tipicord with `docker compose up -d`. *make sure to change the environment variables accordingly*

If you prefer docker run command you can run it with

```bash
docker run -t -d --name tipicord -v ./data:/data -e DISCORD=your-discord-url -e RUNTIPI=your-runtipi-url -e JWT_SECRET=your-jwt-secret ghcr.io/steveiliop56/tipicord:latest
```

## Building

Expand Down Expand Up @@ -55,6 +63,9 @@ If everything succeeds you should have a binary named `tipicord`.
> [!NOTE]
> You can also build for other operating systems/architectures using `GOOS=windows` and `GOARCH=arm64`.
> [!NOTE]
> You can also run a "development" docker compose file by copying the `.env.example` file to `.env`, changing your environment variables and running `docker compose -f docker-compose.dev.yml up --build --force-recreate`. With this way you can test your changes in the docker image too.
## Contributing

This project is still in early stages of development so bugs are to be expected. If you are interested in helping with my terrible go skills, feel free to create a pull request. Any help is appreciated!
Expand Down
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ func init() {
cmdViper.AutomaticEnv()
rootCmd.Flags().String("discord", "", "Discord webhook URL")
rootCmd.Flags().String("runtipi", "", "Runtipi server URL")
rootCmd.Flags().String("jwt", "", "JWT secret")
rootCmd.Flags().String("jwtSecret", "", "JWT secret")
rootCmd.Flags().String("appstore", "https://github.com/runtipi/runtipi-appstore", "Runtipi appstore URL (default https://github.com/runtipi/runtipi-appstore)")
rootCmd.Flags().String("db", "tipicord.db", "Database path (default tipicord.db)")
rootCmd.Flags().String("databasePath", "tipicord.db", "Database path (default tipicord.db)")
rootCmd.Flags().IntP("refresh", "r", 30, "Refresh interval in minutes (default 30)")
cmdViper.BindEnv("jwtSecret", "JWT_SECRET")
cmdViper.BindEnv("databasePath", "DATABASE_PATH")
cmdViper.BindPFlags(rootCmd.Flags())
}

Expand Down
11 changes: 11 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
tipicord:
build:
context: .
dockerfile: Dockerfile
container_name: tipicord
restart: unless-stopped
env_file: .env
volumes:
- ./data:/data

14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
tipicord:
image: ghcr.io/steveiliop56/tipicord:latest
container_name: tipicord
restart: unless-stopped
volumes:
- ./data:/data
environment:
- DISCORD=your-discord-token
- RUNTIPI=runtipi-server-url
- JWT_SECRET=your-jwt-secret
- APPSTORE=https://github.com/runtipi/runtipi-appstore
- DATABASE_PATH=/data/tipicord.db
- REFRESH=30
4 changes: 2 additions & 2 deletions internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ type GetInstalledAppsResponse struct {
type Config struct {
DiscordUrl string `validate:"required" message:"Discord webhook URL is required" mapstructure:"discord"`
RuntipiUrl string `validate:"required" message:"Runtipi URL is required" mapstructure:"runtipi"`
JwtSecret string `validate:"required" message:"JWT secret is required" mapstructure:"jwt"`
JwtSecret string `validate:"required" message:"JWT secret is required" mapstructure:"jwtSecret"`
Appstore string `validate:"required" message:"Appstore URL is required" mapstructure:"appstore"`
DbPath string `validate:"required" message:"Database path is required" mapstructure:"db"`
DbPath string `validate:"required" message:"Database path is required" mapstructure:"databasePath"`
Refresh int `validate:"required" message:"Refresh interval is required" mapstructure:"refresh"`
}

0 comments on commit 321178c

Please sign in to comment.