Skip to content

Commit

Permalink
feat(): nixos flake
Browse files Browse the repository at this point in the history
  • Loading branch information
debuggerpk committed Jan 20, 2025
1 parent 084cb6b commit 898eb6b
Show file tree
Hide file tree
Showing 35 changed files with 378 additions and 126 deletions.
92 changes: 25 additions & 67 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,80 +1,38 @@
# Crafted with ❤ at Breu, Inc. <[email protected]>, Copyright © 2022, 2024.
#
# Functional Source License, Version 1.1, Apache 2.0 Future License
#
# We hereby irrevocably grant you an additional license to use the Software under the Apache License, Version 2.0 that
# is effective on the second anniversary of the date we make the Software available. On or after that date, you may use
# the Software under the Apache License, Version 2.0, in which case the following will apply:
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
FROM cgr.dev/chainguard/wolfi-base AS builder

FROM cgr.dev/chainguard/go:latest AS base
WORKDIR /src

# Install build dependencies - go build toolchain, and git2go build dependencies (libgit2)
RUN apk update && \
apk add --no-cache \
go \
build-base \
cmake \
pkgconf \
openssl-dev \
pcre2-dev \
zlib-dev \
libssh2-dev \
libgit2-dev=1.7.2-r0

# Copy source code
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/go/pkg/mod,sharing=locked \
go mod download

FROM base AS src

WORKDIR /src
COPY . .


# migrate
FROM src AS build-migrate
LABEL io.quantm.artifacts.app="quantm"
LABEL io.quantm.artifacts.component="migrate"

RUN --mount=type=cache,target=/root/go/pkg/mod,sharing=locked \
--mount=type=cache,target=/root/.cache/go-build,sharing=locked \
go build -o ./build/migrate ./cmd/jobs/migrate

FROM cgr.dev/chainguard/git:latest-glibc AS migrate

COPY --from=build-migrate /src/build/migrate /bin/migrate

ENTRYPOINT [ ]
CMD ["/bin/migrate"]


# mothership
FROM src AS build-mothership
LABEL io.quantm.artifacts.app="quantm"
LABEL io.quantm.artifacts.component="mothership"

RUN --mount=type=cache,target=/root/go/pkg/mod,sharing=locked \
--mount=type=cache,target=/root/.cache/go-build,sharing=locked \
go build -o ./build/mothership ./cmd/workers/mothership

FROM cgr.dev/chainguard/git:latest-glibc AS mothership

COPY --from=build-mothership /src/build/mothership /bin/

ENTRYPOINT [ ]
CMD ["/bin/mothership"]


# api
FROM src AS build-api
LABEL io.quantm.artifacts.app="quantm"
LABEL io.quantm.artifacts.component="api"

# Build the quantm binary with static linking
RUN --mount=type=cache,target=/root/go/pkg/mod,sharing=locked \
--mount=type=cache,target=/root/.cache/go-build,sharing=locked \
go build -o ./build/api ./cmd/api
go build -tags static,system_libgit2 \
-o /build/quantm \
./cmd/quantm

FROM cgr.dev/chainguard/git:latest-glibc AS api
# Runtime Stage (Static base)
FROM cgr.dev/chainguard/static AS quantm

COPY --from=build-api /src/build/api /bin/api
COPY --from=builder /build/quantm /bin/quantm

ENTRYPOINT [ ]
CMD ["/bin/api"]
ENTRYPOINT ["/bin/quantm"]
CMD []
2 changes: 1 addition & 1 deletion GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cp .env.example .env
Start the necessary services using Docker Compose. This inlcudes

- temporal-db: Postgres 16.x for required for temporal
- temporal: 1.25.x, it derives the main logic of the application
- temporal: 1.25.x, it drives the main logic of the application
- db: Postgres 16.x for the main database

```bash
Expand Down
11 changes: 11 additions & 0 deletions cmd/quantm/queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"go.breu.io/quantm/internal/pulse"
)

// q_core sets up the core queue.
func q_core() {
q := durable.OnCore()

Expand All @@ -17,38 +18,48 @@ func q_core() {
)

if q != nil {
// Register core activities
q.RegisterActivity(pulse.PersistRepoEvent)
q.RegisterActivity(pulse.PersistChatEvent)

// Register repo workflows and activities
q.RegisterWorkflow(repos.RepoWorkflow)
q.RegisterActivity(repos.NewRepoActivities())

// Register branch workflows and activities
q.RegisterWorkflow(repos.BranchWorkflow)
q.RegisterActivity(repos.NewBranchActivities())
}
}

// q_hooks sets up the hooks queue.
func q_hooks() {
q := durable.OnHooks()

q.CreateWorker()

if q != nil {
// Register pulse activities
q.RegisterActivity(pulse.PersistRepoEvent)
q.RegisterActivity(pulse.PersistChatEvent)

// Register github install workflow and activity
q.RegisterWorkflow(github.InstallWorkflow)
q.RegisterActivity(&github.InstallActivity{})

// Register github sync repos workflow and activity
q.RegisterWorkflow(github.SyncReposWorkflow)
q.RegisterActivity(&github.InstallReposActivity{})

// Register github push workflow and activity
q.RegisterWorkflow(github.PushWorkflow)
q.RegisterActivity(&github.PushActivity{})

// Register github ref workflow and activity
q.RegisterWorkflow(github.RefWorkflow)
q.RegisterActivity(&github.RefActivity{})

// Register github pull request workflow and activity
q.RegisterWorkflow(github.PullRequestWorkflow)
q.RegisterActivity(&github.PullRequestActivity{})
}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
ports:
- 7233:7233
volumes:
- ./deploy/temporal/dynamicconfig/:/etc/temporal/config/dynamicconfig/
- ./tools/temporal/dynamicconfig/:/etc/temporal/config/dynamicconfig/
networks:
- ctrlplane

Expand All @@ -50,7 +50,7 @@ services:
environment:
TEMPORAL_ADDRESS: temporal:7233
TEMPORAL_CORS_ORIGINS: http://localhost:3000
image: temporalio/ui:2.31.2
image: temporalio/ui:2.33.0
ports:
- 8080:8080
networks:
Expand Down
154 changes: 154 additions & 0 deletions flake.lock

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

Loading

0 comments on commit 898eb6b

Please sign in to comment.