Skip to content

Update #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,62 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "fc510a39cff61b849bf5cdff17eb2bd6d0777b49",
"version" : "1.11.5"
"revision" : "78db67e5bf4a8543075787f228e8920097319281",
"version" : "1.18.0"
}
},
{
"identity" : "async-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/async-kit.git",
"state" : {
"revision" : "c3329e444bafbb12d1d312af9191be95348a8175",
"version" : "1.13.0"
"revision" : "a61da00d404ec91d12766f1b9aac7d90777b484d",
"version" : "1.17.0"
}
},
{
"identity" : "console-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/console-kit.git",
"state" : {
"revision" : "a7e67a1719933318b5ab7eaaed355cde020465b1",
"version" : "4.5.0"
"revision" : "447f1046fb4e9df40973fe426ecb24a6f0e8d3b4",
"version" : "4.6.0"
}
},
{
"identity" : "leaf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/leaf.git",
"state" : {
"revision" : "bf1c27928c3f7f93fcdca570d7514727fa23e14e",
"version" : "4.2.2"
"revision" : "6fe0e843c6599f5189e45c7b08739ebc5c410c3b",
"version" : "4.2.4"
}
},
{
"identity" : "leaf-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/leaf-kit.git",
"state" : {
"revision" : "c67a1b06561bfb8a427ed7e50e27792e083f2d3e",
"version" : "1.8.0"
"revision" : "13f2fc4c8479113cd23876d9a434ef4573e368bb",
"version" : "1.10.2"
}
},
{
"identity" : "multipart-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/multipart-kit.git",
"state" : {
"revision" : "0d55c35e788451ee27222783c7d363cb88092fab",
"version" : "4.5.2"
"revision" : "1adfd69df2da08f7931d4281b257475e32c96734",
"version" : "4.5.4"
}
},
{
"identity" : "routing-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/routing-kit.git",
"state" : {
"revision" : "ffac7b3a127ce1e85fb232f1a6271164628809ad",
"version" : "4.6.0"
"revision" : "611bc45c5dfb1f54b84d99b89d1f72191fb6b71b",
"version" : "4.7.2"
}
},
{
Expand All @@ -75,19 +75,19 @@
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "e394bf350e38cb100b6bc4172834770ede1b7232",
"version" : "1.0.3"
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "919eb1d83e02121cdb434c7bfc1f0c66ef17febe",
"version" : "1.0.2"
"revision" : "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version" : "1.1.0"
}
},
{
Expand All @@ -104,17 +104,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "f504716c27d2e5d4144fa4794b12129301d17729",
"version" : "1.0.3"
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "d9825fa541df64b1a7b182178d61b9a82730d01f",
"version" : "2.1.0"
"revision" : "60f13f60c4d093691934dc6cfdf5f508ada1f894",
"version" : "2.6.0"
}
},
{
Expand All @@ -123,70 +123,70 @@
"location" : "https://github.com/apple/swift-experimental-string-processing.git",
"state" : {
"branch" : "main",
"revision" : "0b38ca9bd127bff31ec67a9fa2b60f4d1a23c831"
"revision" : "ba6e49dbee222909d794eb27e37ca3c6d1d51046"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
"version" : "1.4.4"
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
}
},
{
"identity" : "swift-metrics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "53be78637ecd165d1ddedc4e20de69b8f43ec3b7",
"version" : "2.3.2"
"revision" : "971ba26378ab69c43737ee7ba967a896cb74c0d1",
"version" : "2.4.1"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "edfceecba13d68c1c993382806e72f7e96feaa86",
"version" : "2.44.0"
"revision" : "cf281631ff10ec6111f2761052aa81896a83a007",
"version" : "2.58.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "5334d949febb396a4e2e5235e9fbcd9c3c014bb3",
"version" : "1.13.0"
"revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
"version" : "1.19.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "f9ab1c94c80d568efd762d2a638f25162691d766",
"version" : "1.22.1"
"revision" : "a8ccf13fa62775277a5d56844878c828bbb3be1a",
"version" : "1.27.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "a6f9a034e5903024c6bac4ce2c56b157688d844f",
"version" : "2.22.0"
"revision" : "e866a626e105042a6a72a870c88b4c531ba05f83",
"version" : "2.24.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "4e02d9cf35cabfb538c96613272fb027dd0c8692",
"version" : "1.13.1"
"revision" : "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58",
"version" : "1.19.0"
}
},
{
Expand All @@ -204,25 +204,25 @@
"location" : "https://github.com/apple/swift-syntax",
"state" : {
"branch" : "main",
"revision" : "3b7d3ad1afccd53f1e2aaeb1b22437910f80fd2e"
"revision" : "c3f46adfb47efcbb8c61c4aaffb0d792c65ddfbc"
}
},
{
"identity" : "vapor",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "a037bbf91b081ce4f91cbef5a917f8f7844d3daa",
"version" : "4.67.2"
"revision" : "6b96684e150d3b3afcd53df12fe66e6bd9b67a04",
"version" : "4.78.0"
}
},
{
"identity" : "websocket-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/websocket-kit.git",
"state" : {
"revision" : "2d9d2188a08eef4a869d368daab21b3c08510991",
"version" : "2.6.1"
"revision" : "53fe0639a98903858d0196b699720decb42aee7b",
"version" : "2.14.0"
}
}
],
Expand Down
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