-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a new dockerfile using a cross-platform docker
- Loading branch information
Showing
7 changed files
with
85 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM --platform=$BUILDPLATFORM node:20-slim as client-build | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
COPY . /home/app | ||
WORKDIR /home/app | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
RUN pnpm run -r build | ||
|
||
FROM --platform=$BUILDPLATFORM swift:6.0.3-noble as server-build | ||
# Cross compilation based on https://swiftinit.org/articles/cross-compiling-x86_64-linux-to-aarch64-linux | ||
RUN apt update && apt -y install gcc-aarch64-linux-gnu g++-multilib | ||
RUN mkdir /home/swift-cross-compile /home/vapor | ||
WORKDIR /home/swift-cross-compile | ||
COPY docker/swift-cross-platform/* /home/swift-cross-compile/ | ||
|
||
RUN ./download.sh $TARGETPLATFORM && mkdir $TARGETPLATFORM && tar -xzvf swift-$TARGETPLATFORM.tar.gz -C $TARGETPLATFORM | ||
|
||
WORKDIR /home/vapor | ||
|
||
COPY src /home/vapor/src | ||
COPY Package.swift Package.resolved /home/vapor/ | ||
COPY Resources /home/app/Resources | ||
COPY --from=client-build Resources/Views/react.leaf /home/app/Resources/Views/react.leaf | ||
|
||
RUN swift build --destination /home/swift-cross-compile/$TARGETPLATFORM.json -c release --static-swift-stdlib | ||
|
||
FROM ubuntu:noble | ||
RUN mkdir /home/app | ||
WORKDIR /home/app | ||
|
||
COPY --from=server-build /home/vapor/.build/release/MrScroogeServer /home/app/server | ||
COPY Public /home/app/Public | ||
COPY --from=client-build /home/app/Public/react /home/app/Public/react | ||
|
||
EXPOSE 8080 | ||
ENTRYPOINT [ "./MrScroogeServer" ] | ||
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": 1, | ||
"target": "aarch64-unknown-linux-gnu", | ||
"toolchain-bin-dir": "/home/ubuntu/usr/bin", | ||
"sdk": "/usr/aarch64-linux-gnu", | ||
"extra-cc-flags": [ | ||
"-fPIC" | ||
], | ||
"extra-cpp-flags": [ | ||
"-lstdc++", | ||
"-I", "/usr/aarch64-linux-gnu/include/c++/12", | ||
"-I", "/usr/aarch64-linux-gnu/include/c++/12/aarch64-linux-gnu/" | ||
], | ||
"extra-swiftc-flags": [ | ||
"-resource-dir", "/home/swift-cross-compile/aarch64/usr/lib/swift" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
# Download files, from the tarball of the swift page | ||
# They are a copy paste from https://www.swift.org/install/linux/ubuntu/24_04/#latest | ||
echo "Selecting platform for $1" | ||
if [ $1 == "x64_64" ]; then | ||
wget "https://download.swift.org/swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu24.04.tar.gz" -O swift-x86_64.tar.gz | ||
else | ||
wget "https://download.swift.org/swift-6.0.3-release/ubuntu2404-aarch64/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu24.04-aarch64.tar.gz" -O swift-aarch64.tar.gz | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": 1, | ||
"target": "amd64-unknown-linux-gnu", | ||
"toolchain-bin-dir": "/home/ubuntu/usr/bin", | ||
"sdk": "/usr/amd64-linux-gnu", | ||
"extra-cc-flags": [ | ||
"-fPIC" | ||
], | ||
"extra-cpp-flags": [ | ||
"-lstdc++", | ||
"-I", "/usr/amd64-linux-gnu/include/c++/12", | ||
"-I", "/usr/amd64-linux-gnu/include/c++/12/amd64-linux-gnu/" | ||
], | ||
"extra-swiftc-flags": [ | ||
"-resource-dir", "/home/swift-cross-compile/amd64/usr/lib/swift" | ||
] | ||
} |