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

feat: added docker images for namadillo and faucet interface #1105

Merged
merged 1 commit into from
Sep 13, 2024
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
53 changes: 53 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker 🐳

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

env:
GIT_LFS_SKIP_SMUDGE: 1

permissions:
id-token: write
contents: write
packages: write

jobs:
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
images:
- path: "docker/namadillo/Dockerfile"
tag: "namadillo"
- path: "docker/faucet/Dockerfile"
tag: "faucet-interface"

steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push docker image
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.images.path }}
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ matrix.images.tag }}-latest, ${{ matrix.images.tag }}-main
cache-from: type=gha
cache-to: type=gha,mode=max
9 changes: 9 additions & 0 deletions apps/faucet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"@cosmjs/encoding": "^0.29.0",
"buffer": "^6.0.3",
"dompurify": "^3.0.5",
"ethers": "6.7.1",
"framer-motion": "^11.5.4",
"node-forge": "^1.3.1",
"react": "^18.3.0",
"react-dom": "^18.3.0",
Expand All @@ -34,24 +36,31 @@
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/styled-components": "^5.1.26",
"copy-webpack-plugin": "^12.0.2",
"crypto-browserify": "^3.12.0",
"css-loader": "^7.1.2",
"dotenv": "^16.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-react": "^7.35.2",
"eslint-plugin-react-hooks": "^4.6.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"local-cors-proxy": "^1.1.0",
"path-browserify": "^1.0.1",
"postcss": "^8.4.32",
"postcss-loader": "^8.1.0",
"postcss-preset-env": "^9.3.0",
"style-loader": "^4.0.0",
"tailwindcss": "^3.4.1",
"ts-loader": "^9.3.1",
"ts-node": "^10.9.1",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.5.4",
"typescript-plugin-styled-components": "^2.0.0",
"vm-browserify": "^1.1.2",
"webpack": "^5.9.4",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
Expand Down
24 changes: 24 additions & 0 deletions docker/faucet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM rust:1.79 AS builder
WORKDIR /app

RUN apt update && apt install -y nodejs npm clang pkg-config libssl-dev protobuf-compiler curl
RUN npm install -g yarn

COPY .yarnrc.yml tsconfig.base.json package.json yarn.lock .
COPY ./.yarn ./.yarn
COPY ./packages ./packages
COPY ./scripts ./scripts
COPY ./apps/faucet/package.json ./apps/faucet/package.json

RUN yarn

WORKDIR /app/apps/faucet

COPY ./apps/faucet .
RUN yarn
RUN yarn build

FROM nginx:alpine

COPY --from=builder /app/apps/faucet/build /usr/share/nginx/html
COPY ./docker/faucet/nginx.conf /etc/nginx/conf.d/default.conf
File renamed without changes.
File renamed without changes.
21 changes: 16 additions & 5 deletions docker/namadillo.Dockerfile → docker/namadillo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
FROM rust:1.79 as builder
FROM rust:1.79 AS builder
WORKDIR /app

RUN apt update && apt install -y nodejs npm clang pkg-config libssl-dev protobuf-compiler curl
RUN npm install -g yarn

RUN rustup target add wasm32-unknown-unknown
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y

COPY .yarnrc.yml tsconfig.base.json package.json yarn.lock .
COPY ./.yarn ./.yarn
COPY ./packages ./packages
COPY ./scripts ./scripts
COPY ./apps/namadillo/package.json ./apps/namadillo/package.json

RUN yarn

WORKDIR /app/apps/namadillo
COPY ./apps/namadillo/scripts ./scripts

RUN yarn wasm:build

COPY ./apps/namadillo .
RUN yarn
RUN yarn build
RUN yarn && yarn build

FROM nginx:alpine
WORKDIR /app

COPY --from=builder /app/apps/namadillo/dist /usr/share/nginx/html
COPY ./docker/namadillo-nginx.conf /etc/nginx/conf.d/default.conf
COPY ./docker/namadillo.config.tom[l] /usr/share/nginx/html/config.toml
COPY ./docker/namadillo/nginx.conf /etc/nginx/conf.d/default.conf
# COPY ./docker/namadillo/config.tom[l] /usr/share/nginx/html/config.toml
COPY --chmod=0755 ./docker/namadillo/bootstrap_config.sh /docker-entrypoint.d/bootstrap_config.sh

RUN chown nginx:nginx /docker-entrypoint.d/bootstrap_config.sh
25 changes: 25 additions & 0 deletions docker/namadillo/bootstrap_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

CONFIG_PATH="/usr/share/nginx/html/config.toml"

# if the config.toml file doesn't exist, we create it and we try to populate it from environemnt variables
# Otherwise we try to replace the settings from environemnt variables
if [ ! -f $CONFIG_PATH ]; then
echo "Bootstrapping new configuration file at $CONFIG_PATH"
touch $CONFIG_PATH
if [[ -n $INDEXER_URL ]]; then
echo "indexer_url = \"${INDEXER_URL}\"" >> $CONFIG_PATH
fi
if [[ -n $RPC_URL ]]; then
echo "rpc_url = \"${RPC_URL}\"" >> $CONFIG_PATH
fi
else
echo "Using configuration file at $CONFIG_PATH"
if [[ -n $INDEXER_URL ]]; then
sed -r -i "s~#?indexer_url = .*~indexer_url = \"${INDEXER_URL}\"~g" $CONFIG_PATH
fi
if [[ -n $RPC_URL ]]; then
sed -r -i "s~#?rpc_url = .*~rpc_url = \"${RPC_URL}\"~g" $CONFIG_PATH
fi
cat $CONFIG_PATH
fi
11 changes: 11 additions & 0 deletions docker/namadillo/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ $uri.html /index.html;
}
gzip on;
gzip_types text/plain text/css application/javascript application/json application/vnd.ms-fontobject application/xml+rss application/atom+xml font/opentype font/ttf image/svg+xml;
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"lint": "wsrun -l --exclude-missing -c lint",
"lint:fix": "wsrun -l --exclude-missing -c lint:fix",
"lint:ci": "wsrun -l --exclude-missing -c lint:ci",
"prepare": "husky install"
"prepare": "husky install",
"docker-build-faucet": "docker build -f docker/faucet/Dockerfile .",
"docker-build-namadillo": "docker build -f docker/namadillo/Dockerfile ."
},
"devDependencies": {
"@release-it/conventional-changelog": "^8.0.1",
Expand Down
Loading
Loading