Skip to content

Commit

Permalink
Merge branch 'development' into SERVICES-2563-integrate-assets-cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
cfaur09 committed Oct 31, 2024
2 parents cc2ad1b + 62cef99 commit 5e54328
Show file tree
Hide file tree
Showing 50 changed files with 2,783 additions and 1,905 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish Docker image

on:
release:
types: [published]
workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18' # Specify your Node.js version

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: multiversx/mx-api-service

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18.19-alpine

WORKDIR /app
RUN chown -R node:node /app

USER node
RUN mkdir -p /app/dist/src
COPY --chown=node . /app

RUN npm install
RUN npm run init
RUN npm run build

EXPOSE 3001
RUN chmod +x entrypoint.sh

CMD ["./entrypoint.sh"]
1 change: 1 addition & 0 deletions config/config.devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
Expand Down
1 change: 1 addition & 0 deletions config/config.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
Expand Down
1 change: 1 addition & 0 deletions config/config.testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
Expand Down
46 changes: 46 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
# ENV VARIABLES
# MVX_ENV - defines what config to copy (default devnet)
# ELASTICSEARCH_URL - defines custom elasticsearch url - eg https://devnet-index.multiversx.com
# GATEWAY_URL - defines custom gateway url - eg https://devnet-gateway.multiversx.com
# REDIS_IP - defines redis ip - default 127.0.0.1

# CHECK IF ENV IS DEFINED
if [ -n "$MVX_ENV" ] && [ "$MVX_ENV" = "devnet" ]; then
# Copy config file
cp ./config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml

if [ $? -eq 0 ]; then
echo "Config file copied successfully from config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml"
else
echo "Failed to copy the file."
fi

else
cp ./config/config.devnet.yaml /app/dist/config/config.yaml

if [ $? -eq 0 ]; then
echo "Default config file copied successfully from config/config.devnet.yaml /app/dist/config/config.yaml"
else
echo "Failed to copy the file."
fi
fi

# Replaces urls if defined
if [ -n "$REDIS_IP" ]; then
echo "Redis IP defined: ${REDIS_IP}, replacing in config"
sed -i "s|redis: '127.0.0.1'|redis: '${REDIS_IP}'|g" /app/dist/config/config.yaml
fi

if [ -n "$ELASTICSEARCH_URL" ]; then
echo "Elasticsearch url defined: ${ELASTICSEARCH_URL}, replacing in config"
sed -i "/^ elastic:/!b; n; s|.*| - '${ELASTICSEARCH_URL}'|" /app/dist/config/config.yaml
fi

if [ -n "$GATEWAY_URL" ]; then
echo "Gateway url defined: ${GATEWAY_URL}, replacing in config"
sed -i "/^ gateway:/!b; n; s|.*| - '${GATEWAY_URL}'|" /app/dist/config/config.yaml
fi


exec /usr/local/bin/node dist/src/main.js
Loading

0 comments on commit 5e54328

Please sign in to comment.