-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from glencoden/staging
Staging
- Loading branch information
Showing
5 changed files
with
85 additions
and
7 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
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,44 @@ | ||
# Stage one - build the app | ||
FROM rust:1.76 as rustbuilder | ||
|
||
# This is set to disable caching after this line when there are new commits (./scripts/validate-cache.sh) | ||
ARG COMMIT_HASH=95ce4cfedd21e9e6d099ce9fa7fc0d6987da342e | ||
|
||
ARG DATABASE_URL | ||
ARG UUID | ||
|
||
RUN apt-get update && apt-get install -y git | ||
|
||
WORKDIR /usr/src | ||
|
||
RUN git clone -b main --single-branch https://github.com/glencoden/cards-backend.git . | ||
|
||
RUN cargo --config ${DATABASE_URL} | ||
RUN cargo --config ${UUID} | ||
|
||
RUN cargo build --release | ||
|
||
# Stage two - generate tailwind css | ||
FROM node:18 as nodebuilder | ||
|
||
WORKDIR /usr/src | ||
|
||
COPY --from=rustbuilder /usr/src . | ||
|
||
RUN npm install --production=false && npm run tailwind:build | ||
|
||
# Stage three - run the app | ||
FROM debian:bookworm-slim | ||
|
||
ARG DATABASE_URL | ||
ARG UUID | ||
|
||
ENV DATABASE_URL=${DATABASE_URL} | ||
ENV UUID=${UUID} | ||
|
||
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=rustbuilder /usr/src/target/release/cards-backend . | ||
COPY --from=nodebuilder /usr/src/assets /assets | ||
|
||
CMD ["./cards-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,20 @@ | ||
# fetch remote commit info | ||
git_response=$(git ls-remote https://github.com/glencoden/cards-backend.git | egrep 'main|merge') | ||
|
||
# parse for commit hash | ||
parsed_response=$(echo "$git_response" | tr '\t' ' ') | ||
commit_hash=$(echo "$parsed_response" | cut -d' ' -f1) | ||
|
||
# store the exit status of the git command in a variable | ||
git_exit_status=$? | ||
|
||
if [ $git_exit_status -eq 0 ]; then | ||
sed -i "" -e "5s/.*/ARG COMMIT_HASH=$commit_hash/" contexts/cards/Dockerfile | ||
else | ||
echo "git command failed" | ||
fi | ||
|
||
# if the commit hash is no option, you can invalidate docker cache every run with a timestamp: | ||
|
||
# cache_time=$(date +%s) | ||
# sed -i "" -e "6s/.*/ARG CACHE_TIME=$cache_time/" contexts/tsc/Dockerfile |
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