-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
61 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,28 @@ | ||
FROM debian:latest | ||
|
||
# Path to the executable to run | ||
ARG BIN_PATH | ||
|
||
# Install OpenSSL - required for Axum applications | ||
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a new user and group to run the application | ||
RUN groupadd -r app && useradd -r -g app app | ||
|
||
RUN mkdir -p /opt/app && chown app:app /opt/app | ||
# Set the working directory | ||
WORKDIR /opt/app | ||
|
||
|
||
# Switch from root to the "app" user | ||
USER app | ||
COPY --chown=app:app ${BIN_PATH:?missing} /opt/app/backend | ||
|
||
# Expose the port the server listens on | ||
EXPOSE 8080 | ||
|
||
ENV XDG_DATA_HOME="/opt/app/" | ||
ENV RUST_BACKTRACE=1 | ||
|
||
# Run the application | ||
CMD "/opt/app/backend" |
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,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit # abort on nonzero exitstatus | ||
set -o nounset # abort on unbound variable | ||
set -o pipefail # don't hide errors within pipes | ||
|
||
TARGET="x86_64-unknown-linux-gnu" | ||
BIN_NAME="backend" | ||
REPO_ROOT="$(readlink -f "$(dirname "${0}")/../../..")" | ||
BACKEND_DIR="$(readlink -f "$(dirname "${0}")")" | ||
RELATIVE_RELEASE_DIR="target/${TARGET}/release" | ||
echo "REPO_ROOT=${REPO_ROOT}" | ||
echo "BACKEND_DIR=${BACKEND_DIR}" | ||
|
||
cargo zigbuild --release --target "${TARGET}" --bin "${BIN_NAME}" | ||
|
||
docker buildx build "${REPO_ROOT}/${RELATIVE_RELEASE_DIR}" \ | ||
--platform=linux/amd64 \ | ||
-f "${BACKEND_DIR}/Dockerfile" \ | ||
-t "${BIN_NAME}" \ | ||
--build-arg BIN_PATH="${BIN_NAME}" | ||
|
||
echo "built docker image. You can run via:" | ||
echo "\"docker run -it -p HOST_PORT:8080 ${BIN_NAME}\"" |
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
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
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