Skip to content

Commit

Permalink
Add github workflow build
Browse files Browse the repository at this point in the history
  • Loading branch information
xZero707 committed Apr 20, 2024
1 parent 1f2209a commit 3c1f13d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
assignees:
- "xZero707"

# Maintain Docker image dependencies
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "xZero707"
38 changes: 38 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build docker image

on:
push:
branches: master

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: checkout code
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 DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.PAT_TOKEN}}
-
name: Build and push
uses: docker/[email protected]
with:
files: build/docker-bake.hcl
push: true
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ WORKDIR /app

CMD [ "/app/tg-events-service" ]


LABEL maintainer="Aleksandar Puharic <[email protected]>" \
org.opencontainers.image.documentation="https://github.com/xZero707/telegram-event-server/wiki" \
org.opencontainers.image.source="https://github.com/xZero707/telegram-event-server" \
org.opencontainers.image.description="Telegram Event Server 1.0.0 - Build ${TARGETPLATFORM}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.version="1.0.0"

ENV ALLOWED_ORIGINS="http://127.0.0.1"
EXPOSE 8080/TCP
79 changes: 79 additions & 0 deletions build/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
group "default" {
targets = [
"1_0_0",
]
}

target "build-dockerfile" {
dockerfile = "Dockerfile"
}

target "build-platforms" {
platforms = ["linux/amd64", "linux/aarch64"]
}

target "build-common" {
pull = true
}

variable "REGISTRY_CACHE" {
default = "ghcr.io/xZero707/telegram-event-server-cache"
}

######################
# Define the functions
######################

# Get the arguments for the build
function "get-args" {
params = [version, patch_version]
result = {
WP_VERSION = version
WP_PATCH_VERSION = patch_version
}
}

# Get the cache-from configuration
function "get-cache-from" {
params = [version]
result = [
"type=registry,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
]
}

# Get the cache-to configuration
function "get-cache-to" {
params = [version]
result = [
"type=registry,mode=max,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
]
}

# Get list of image tags and registries
# Takes a version and a list of extra versions to tag
# eg. get-tags("1.0.0", ["1", "1.0", "latest"])
function "get-tags" {
params = [version, extra_versions]
result = concat(
[
"ghcr.io/xZero707/telegram-event-server:${version}"
],
flatten([
for extra_version in extra_versions : [
"ghcr.io/xZero707/telegram-event-server:${extra_version}"
]
])
)
}

##########################
# Define the build targets
##########################

target "1_0_0" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("1.0.0")
cache-to = get-cache-to("1.0.0")
tags = get-tags("1.0.0", ["1", "1.0", "latest"])
args = get-args("1.0.0", "1.0.0")
}

0 comments on commit 3c1f13d

Please sign in to comment.