Skip to content
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

[SKIP CI] Fix docker ci #86

Merged
merged 1 commit into from
Nov 7, 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
2 changes: 2 additions & 0 deletions .github/workflows/node-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
changes_found: ${{ steps.check_changes.outputs.changes_found }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Check for package changes and commit message
id: check_changes
run: |
Expand Down
32 changes: 24 additions & 8 deletions packages/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
# Build stage
FROM node:18-alpine as builder

# Set working directory
WORKDIR /app
COPY ./packages/node ./
RUN npm install -g --force yarn@latest && \
yarn pack --filename app.tgz && \
rm -rf /root/.npm /root/.cache

# Copy all packages
COPY ./packages ./packages

# Copy tsconfig.json
COPY ./tsconfig.json ./tsconfig.json

# Copy build script
COPY ./scripts/build.sh ./scripts/build.sh

# Install dependencies and build
RUN ./scripts/build.sh packages/node

# Production stage
FROM node:18-alpine
RUN apk add --no-cache tini curl git
COPY --from=builder /app/app.tgz /app.tgz
RUN tar -xzvf /app.tgz --strip 1 && \

# Copy .tgz file from builder
COPY --from=builder /app/packages/node/app.tgz /app.tgz

# Install production dependencies
RUN apk add --no-cache tini curl git && \
tar -xzvf /app.tgz --strip 1 && \
rm /app.tgz && \
yarn install --production && \
yarn cache clean && \
rm -rf /root/.npm /root/.cache

# Set Entry point and command
ENTRYPOINT ["/sbin/tini", "--", "bin/run"]
CMD ["-f","/app"]
CMD ["-f","/app"]
18 changes: 18 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
set -e

apk add --no-cache jq
npm install -g --force yarn@latest
cd "$1"

# Modifies the package.json to replace "workspace:*" versions with actual versions
jq -r '.dependencies | to_entries[] | select(.value == "workspace:*") | .key' package.json | while read -r dep; do
directory=$(jq --arg dep "$dep" -r '.compilerOptions.paths[$dep][0]' ../../tsconfig.json | cut -d'/' -f 2)
version=$(jq --arg directory "$directory" -r '.version' ../"$directory"/package.json)
if [ "$version" != null ]; then
jq --arg dep "$dep" --arg version "$version" -r '.dependencies[$dep] = $version' package.json > package.tmp.json && mv package.tmp.json package.json
fi
done

yarn pack --filename app.tgz
rm -rf /root/.npm /root/.cache
2 changes: 1 addition & 1 deletion tsconfig.json
jiqiang90 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"references": [
{"path": "packages/common-algorand"},
{"path": "packages/node"},
{"path": "packages/types"},
{"path": "packages/types"}
],
"include": ["packages/**/*"],
"exclude": ["**/node_modules/**"],
Expand Down