-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ddex to audius-compose and improve its build (#7013)
- Loading branch information
Showing
8 changed files
with
86 additions
and
27 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
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,14 @@ | ||
version: '3.9' | ||
|
||
services: | ||
ddex: | ||
container_name: ddex | ||
build: | ||
context: ${PROJECT_ROOT}/packages/ddex | ||
dockerfile: Dockerfile | ||
args: | ||
app_name: ddex | ||
TURBO_TEAM: '${TURBO_TEAM}' | ||
TURBO_TOKEN: '${TURBO_TOKEN}' | ||
profiles: | ||
- ddex |
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,11 @@ | ||
node_modules/ | ||
dist/ | ||
logs/ | ||
.git/ | ||
.gitignore | ||
.vscode/ | ||
README.md | ||
Dockerfile | ||
.dockerignore | ||
.env | ||
.env.* |
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
FROM node:18.17-slim | ||
|
||
RUN apt update && apt install -y python3 make gcc g++ | ||
|
||
ENV WORKDIR /app | ||
WORKDIR ${WORKDIR} | ||
FROM node:18.17-slim as builder | ||
RUN apt-get update && apt-get install -y python3 make gcc g++ | ||
WORKDIR /app | ||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
|
||
COPY index.html package.json postcss.config.js tailwind.config.js tsconfig.json tsconfig.node.json vite.config.ts ./ | ||
ADD src ./src | ||
ADD public ./public | ||
ADD scripts ./scripts | ||
RUN chmod +x ./scripts/docker-entrypoint.sh | ||
FROM alpine:latest | ||
WORKDIR /app | ||
COPY --from=builder /app/dist /tmp/dist | ||
|
||
RUN npm install | ||
RUN apk add --no-cache findutils coreutils | ||
COPY ./scripts/docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] |
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,14 @@ | ||
# To use this file for testing on staging: | ||
# 0. npm i && npm run build | ||
# 1. in docker-compose.ddex.yml, set dockerfile to Dockerfile.fast | ||
# 2. comment out dist/ in .dockerignore | ||
# 3. run audius-compose push --prod "ddex" (first do env = os.environ.copy() and env["DOCKER_DEFAULT_PLATFORM"] = "linux/amd64") in the audius-compose build command code) | ||
|
||
FROM alpine:latest | ||
WORKDIR /app | ||
RUN apk add --no-cache findutils coreutils | ||
COPY dist /tmp/dist | ||
|
||
COPY ./scripts/docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] |
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 |
---|---|---|
@@ -1,20 +1,29 @@ | ||
#!/bin/sh | ||
|
||
FIRST_RUN_FLAG="./.firstrun" | ||
# Directory where build artifacts are stored in the image before being copied to the volume | ||
TEMP_BUILD_DIR="/tmp/dist" | ||
|
||
if [ ! -f "$FIRST_RUN_FLAG" ]; then | ||
echo "Building dist..." | ||
npm run build | ||
# Directory mounted as a volume | ||
VOLUME_DIR="/app/dist" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Successfully built dist" | ||
touch "$FIRST_RUN_FLAG" | ||
else | ||
echo "'npm run build' failed with exit code $?. Exiting..." | ||
exit 1 | ||
fi | ||
# Calculate the current checksum of the temporary build directory | ||
CHECKSUM_FILE="$VOLUME_DIR/.checksum" | ||
current_checksum=$(find "$TEMP_BUILD_DIR" -type f -exec md5sum {} \; | md5sum | cut -d' ' -f1) | ||
|
||
# Read the last checksum (if it exists) | ||
last_checksum="" | ||
if [ -f "$CHECKSUM_FILE" ]; then | ||
last_checksum=$(cat "$CHECKSUM_FILE") | ||
fi | ||
|
||
# Compare checksums and copy if different | ||
if [ "$current_checksum" != "$last_checksum" ]; then | ||
echo "Changes detected. Updating files in volume..." | ||
cp -r $TEMP_BUILD_DIR/* $VOLUME_DIR/ | ||
echo "$current_checksum" > "$CHECKSUM_FILE" | ||
else | ||
echo "dist already built" | ||
echo "No changes detected. No update needed." | ||
fi | ||
|
||
exec npm run serve | ||
# Keep the container running by tailing /dev/null | ||
tail -f /dev/null |