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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Build context for backend/Dockerfile is the repo root (the backend's
# Package.swift references the local ../CocoaHeadsCore package).
# Exclude everything except what the image build needs.
*
!backend
!CocoaHeadsCore
backend/.build/
backend/.swiftpm/
CocoaHeadsCore/.build/
CocoaHeadsCore/.swiftpm/
49 changes: 0 additions & 49 deletions .github/workflows/deploy-backend.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// Created by Mauricio on 5/7/25.
//

import SwiftUI
import Foundation

// TODO: .largeLink(URL) -> LPLinkPresentation

public indirect enum EventDetailUI: Codable, Sendable {
case card(title: String?, edges: Edge.Set, insetBy: CGFloat?, ui: [EventDetailUI])
case card(title: String?, edges: ServerEdge.Set, insetBy: CGFloat?, ui: [EventDetailUI])
case carousel(ui: [EventDetailUI])
// TODO: Action -> openURL instead of direct URL
case callToAction(title: String, url: URL, systemImage: String?)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
//
// Edge+Codable.swift
// CocoaHeadsKit
// ServerEdge+Codable.swift
// CocoaHeadsCore
//
// Created by Mauricio on 5/7/25.
//

import SwiftUI

// TODO: Move this to `Common`

extension Edge.Set: @retroactive Codable {
extension ServerEdge.Set: Codable {
private enum CodingKeys: String, CodingKey {
case top, leading, bottom, trailing, all, horizontal, vertical
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
var edges: Edge.Set = []
var edges: ServerEdge.Set = []

if try container.decodeIfPresent(Bool.self, forKey: .top) == true {
edges.insert(.top)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ServerEdge.swift
// CocoaHeadsCore
//
// Created by Mauricio on 8/4/26.
//

// Platform-neutral mirror of SwiftUI.Edge, so server-driven UI models
// compile on Linux and stay free of SwiftUI. Raw values match SwiftUI's,
// making the bridge to SwiftUI.Edge.Set a plain rawValue conversion.
public enum ServerEdge: Int8, CaseIterable, Sendable {
case top, leading, bottom, trailing

public struct Set: OptionSet, Sendable {
public let rawValue: Int8

public init(rawValue: Int8) {
self.rawValue = rawValue
}

public init(_ e: ServerEdge) {
self.init(rawValue: 1 << e.rawValue)
}

public static let top = Set(.top)
public static let leading = Set(.leading)
public static let bottom = Set(.bottom)
public static let trailing = Set(.trailing)
public static let horizontal: Set = [.leading, .trailing]
public static let vertical: Set = [.top, .bottom]
public static let all: Set = [.top, .leading, .bottom, .trailing]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct EventDetailRenderer: View {
private func render(ui: EventDetailUI) -> some View {
switch ui {
case .card(title: let title, edges: let edges, insetBy: let insets, ui: let innerUI):
Card(title: title, contentInset: (edges, insets)) {
Card(title: title, contentInset: (edges.swiftUI, insets)) {
EventDetailRenderer(ui: innerUI)
}
case .carousel(ui: let innerUI):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// ServerEdge+SwiftUI.swift
// CocoaHeadsKit
//
// Created by Mauricio on 8/4/26.
//

import CocoaHeadsCore
import SwiftUI

extension ServerEdge.Set {
/// SwiftUI counterpart of this edge set, for use in view modifiers.
public var swiftUI: SwiftUI.Edge.Set {
.init(rawValue: rawValue)
}
}

extension ServerEdge {
/// SwiftUI counterpart of this edge.
public var swiftUI: SwiftUI.Edge {
switch self {
case .top: .top
case .leading: .leading
case .bottom: .bottom
case .trailing: .trailing
}
}
}
9 changes: 6 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ WORKDIR /build
# This creates a cached layer that can be reused
# as long as your Package.swift/Package.resolved
# files do not change.
COPY ./Package.* ./
# CocoaHeadsCore is a local package referenced as ../CocoaHeadsCore,
# so it must sit next to /build inside the container.
COPY CocoaHeadsCore /CocoaHeadsCore
COPY backend/Package.* ./
RUN swift package resolve \
$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)

# Copy entire repo into container
COPY . .
# Copy backend sources into container
COPY backend/ ./

RUN mkdir /staging

Expand Down
9 changes: 6 additions & 3 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ services:
app:
image: backend:latest
build:
context: .
context: ..
dockerfile: backend/Dockerfile
environment:
<<: *shared_environment
depends_on:
Expand All @@ -41,7 +42,8 @@ services:
migrate:
image: backend:latest
build:
context: .
context: ..
dockerfile: backend/Dockerfile
environment:
<<: *shared_environment
depends_on:
Expand All @@ -52,7 +54,8 @@ services:
revert:
image: backend:latest
build:
context: .
context: ..
dockerfile: backend/Dockerfile
environment:
<<: *shared_environment
depends_on:
Expand Down
Loading