Skip to content
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
20 changes: 19 additions & 1 deletion Package.resolved

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

2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ let package = Package(
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
.package(url: "https://github.com/vapor/redis.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.102.0"),
],
targets: [
Expand All @@ -71,6 +72,7 @@ let package = Package(
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
.product(name: "Parsing", package: "swift-parsing"),
.product(name: "Redis", package: "redis"),
.product(name: "ShellOut", package: "ShellOut"),
.product(name: "SwiftPMDataModel-auto", package: "swift-package-manager"),
.product(name: "SwiftPMPackageCollections", package: "swift-package-manager"),
Expand Down
10 changes: 10 additions & 0 deletions Sources/App/configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

import Fluent
import FluentPostgresDriver
import Redis
import Vapor


@discardableResult
public func configure(_ app: Application) async throws -> String {
#if DEBUG && os(macOS)
Expand Down Expand Up @@ -49,6 +51,7 @@ public func configure(_ app: Application) async throws -> String {
// This parameter could also be made configurable via an env variable.
let maxConnectionsPerEventLoop = 3

// Setup database connection
guard
let host = Environment.get("DATABASE_HOST"),
let port = Environment.get("DATABASE_PORT").flatMap(Int.init),
Expand All @@ -75,6 +78,13 @@ public func configure(_ app: Application) async throws -> String {
sqlLogLevel: .debug),
as: .psql)

// Setup Redis connection
do {
app.redis.configuration = try RedisConfiguration(hostname: "redis")
} catch {
app.logger.warning("Failed to configure Redis, caching disabled. Error: \(error)")
}

do { // Migration 001 - schema 1.0
app.migrations.add(CreatePackage())
app.migrations.add(CreateRepository())
Expand Down
43 changes: 29 additions & 14 deletions app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,38 @@ services:
- backend

alerting:
image: registry.gitlab.com/finestructure/swiftpackageindex:${VERSION}
<<: *shared
depends_on:
- migrate
entrypoint: ["/bin/bash"]
command: ["-c", "--",
image: registry.gitlab.com/finestructure/swiftpackageindex:${VERSION}
<<: *shared
depends_on:
- migrate
entrypoint: ["/bin/bash"]
command: ["-c", "--",
"trap : TERM INT; while true; do ./Run alerting --env ${ENV} --time-period ${ALERTING_TIME_PERIOD:-4} --limit ${ALERTING_LIMIT:-2000}; sleep ${ALERTING_SLEEP:-300}; done"
]
deploy:
resources:
limits:
memory: 0.5GB
restart_policy:
]
deploy:
resources:
limits:
memory: 0.5GB
restart_policy:
max_attempts: 5
networks:
- backend
networks:
- backend
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alerting: section was indented with 4 spaces rather than 2 spaces like the rest.


redis:
# Eventually we'll probably want to use redis/redis-stack-server:7.4.0-v1 here,
# which excludes the RedisInsight GUI front-end.
image: redis/redis-stack:7.4.0-v1
environment:
REDIS_ARGS: '--maxmemory 4GB --maxmemory-policy allkeys-lru'
ports:
- '6379:6379'
- '8001:8001'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to clarify the situation around the ports before deploying this in prod. I don't think they're open due to the firewall sitting in front of it but it needs double checking.

We should be able to connect to the 8001 port for the insights GUI via an ssh tunnel/port forward. I did that i the past but not in a while - need to dig up the commands again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it’s a swarm, there may need to be firewalls opened between the hosts - I don’t think it’s available in prod based on the current network security groups.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the swarm hosts are in the same NSG and I'm pretty sure we only need to open 8001 (to Bastion) in case we want to use the Redis GUI.

I've verified that this is working as intended on dev (which is technically also a swarm albeit with just one node).

deploy:
resources:
limits:
memory: 4.2GB
networks:
- backend

migrate:
image: registry.gitlab.com/finestructure/swiftpackageindex:${VERSION}
Expand Down
Loading