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: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@
"args": [],
"cwd": "${workspaceFolder:swiftregex}",
"preLaunchTask": "swift: Build Release BuilderTester"
},
{
"type": "lldb",
"request": "launch",
"sourceLanguages": ["swift"],
"name": "Debug App",
"program": "${workspaceFolder:swiftregex}/.build/debug/App",
"args": [],
"cwd": "${workspaceFolder:swiftregex}",
"preLaunchTask": "swift: Build Debug App"
},
{
"type": "lldb",
"request": "launch",
"sourceLanguages": ["swift"],
"name": "Release App",
"program": "${workspaceFolder:swiftregex}/.build/release/App",
"args": [],
"cwd": "${workspaceFolder:swiftregex}",
"preLaunchTask": "swift: Build Release App"
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lldb.library": "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB",
"lldb.launch.expressions": "native"
}
29 changes: 20 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY Public ./Public/
RUN npx webpack --config webpack.prod.js


FROM swiftlang/swift:nightly-main-focal as swift
FROM swiftlang/swift:nightly-main-jammy as swift
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update && apt-get -q dist-upgrade -y \
&& apt-get install -y --no-install-recommends libsqlite3-dev \
Expand All @@ -25,25 +25,36 @@ COPY ./Package.* ./
RUN swift package resolve

COPY . .
RUN swift build -c release -Xswiftc -enable-testing
RUN swift build -c release --static-swift-stdlib -Xswiftc -enable-testing

WORKDIR /staging
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/Run" ./ \
&& mv /build/Public ./Public && chmod -R a-w ./Public \
&& mv /build/.build ./.build && chmod -R a-w ./.build

RUN cp "$(swift build --package-path /build -c release --show-bin-path)/App" ./

FROM swiftlang/swift:nightly-main-focal
RUN find -L "$(swift build --package-path /build -c release --show-bin-path)/" -regex '.*\.resources$' -exec cp -Ra {} ./ \;

RUN [ -d /build/Public ] && { mv /build/Public ./Public && chmod -R a-w ./Public; } || true
RUN [ -d /build/Resources ] && { mv /build/Resources ./Resources && chmod -R a-w ./Resources; } || true
RUN [ -d /build/.build ] && { mv /build/.build ./.build && chmod -R a-w ./.build; } || true


FROM swiftlang/swift:nightly-main-jammy
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update && apt-get -q dist-upgrade -y && rm -r /var/lib/apt/lists/*\
&& useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get -q install -y \
ca-certificates \
tzdata \
&& rm -r /var/lib/apt/lists/*

RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor

WORKDIR /app
COPY --from=swift --chown=vapor:vapor /staging /app

USER vapor:vapor
EXPOSE 8080

ENTRYPOINT ["./Run"]
ENTRYPOINT ["./App"]
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]

86 changes: 43 additions & 43 deletions Package.resolved

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

6 changes: 2 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand All @@ -19,7 +19,6 @@ let package = Package(
.product(name: "_StringProcessing", package: "swift-experimental-string-processing"),
.product(name: "_RegexParser", package: "swift-experimental-string-processing"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxParser", package: "swift-syntax"),
],
swiftSettings: [
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"]),
Expand Down Expand Up @@ -70,7 +69,7 @@ let package = Package(
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
]
),
.target(
.executableTarget(
name: "App",
dependencies: [
.product(name: "Vapor", package: "vapor"),
Expand All @@ -80,7 +79,6 @@ let package = Package(
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
]
),
.executableTarget(name: "Run", dependencies: [.target(name: "App")]),
.testTarget(
name: "RegexTests", dependencies: [
.target(name: "BuilderTester"),
Expand Down
1 change: 1 addition & 0 deletions Public/scss/default.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/utilities";
Expand Down
4 changes: 3 additions & 1 deletion Sources/App/configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ public func configure(_ app: Application) throws {
app.middleware = Middlewares()
app.middleware.use(CommonErrorMiddleware())
app.middleware.use(CustomHeaderMiddleware())

let publicDirectory = "\(app.directory.publicDirectory)/dist"
app.middleware.use(FileMiddleware(publicDirectory: publicDirectory))

app.http.server.configuration.supportPipelining = true
app.http.server.configuration.port = Environment.process.PORT.flatMap { Int($0) } ?? 8080
app.http.server.configuration.requestDecompression = .enabled
app.http.server.configuration.responseCompression = .enabled
app.http.server.configuration.supportPipelining = true

app.views.use(.leaf)
app.leaf.configuration.rootDirectory = publicDirectory
Expand Down
Loading