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

St 619 localterra fix #469

Merged
merged 12 commits into from
Jul 18, 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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Dockerfile
docker-compose.yml
build/
node_modules/
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SASS_PATH=node_modules:src/styles

# Docker Compose
COMPOSE_PROJECT_NAME=localterra
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM node:16 as builder

WORKDIR /app

RUN set -eux &&\
apt update &&\
apt install -y \
libudev-dev \
libusb-1.0-0-dev

COPY package*.json ./
COPY tsconfig.json ./

RUN set -eux && \
npm install -g typescript react-scripts && \
npm install --include=dev

COPY . .

ARG REACT_APP_ASSETS="https://assets.terra.money" \
REACT_APP_STATION_ASSETS="https://station-assets.terra.money"

ENV REACT_APP_ASSETS=${REACT_APP_ASSETS} \
REACT_APP_STATION_ASSETS=${REACT_APP_STATION_ASSETS}

RUN set -eux && \
npm run build --openssl-legacy-provider

###############################################################################

FROM node:16 as reloader

ARG REACT_APP_ASSETS="https://assets.terra.money" \
REACT_APP_STATION_ASSETS="https://station-assets.terra.money"

ENV REACT_APP_ASSETS=${REACT_APP_ASSETS} \
REACT_APP_STATION_ASSETS=${REACT_APP_STATION_ASSETS}

# add node modules to parent directory
COPY --from=builder /app/node_modules /app/node_modules
ENV PATH=/app/node_modules/.bin:$PATH

# use bind mount to enable hot reloading
WORKDIR /app/src
COPY . .

CMD ["npm", "run", "start"]

###############################################################################

FROM node:16-alpine

WORKDIR /app
COPY --from=builder /app/build .

RUN set -eux && \
npm install -g serve

CMD ["serve", "-s", "."]
44 changes: 44 additions & 0 deletions docker-assets/haproxy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
global
log stdout format raw daemon debug
#chroot /var/lib/haproxy
#stats socket /var/run/haproxy.sock mode 660 level admin expose-fd listeners
#stats timeout 30s
user haproxy
group haproxy
daemon

defaults
log global
mode http
option httplog
option dontlognull
option forwardfor
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000

frontend stats
bind *:8444
stats enable
stats uri /
stats refresh 10s

frontend localterra
bind *:1317
http-response set-header Access-Control-Allow-Origin *
http-response set-header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
http-response set-header Access-Control-Allow-Headers "*"
http-response set-header Access-Control-Max-Age 3600
default_backend localterra_lcd_backend

backend localterra_lcd_backend
mode http
server localterra_lcd localterra:1317
66 changes: 66 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: '3.9'

###############################################################################
services:

haproxy:
image: haproxy:2.8.0-alpine
volumes:
- ./docker-assets/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
networks:
- default
ports:
- '1317:1317'
- '8444:8444'

localterra:
image: ghcr.io/terra-money/localterra:${TERRA_VERSION:-latest}
platform: linux/amd64
hostname: terrad
volumes:
- terra:/app
networks:
- default

assets:
image: ghcr.io/terra-money/station-assets:1.0.1
hostname: assets
networks:
- default
ports:
- '3001:3001'

station:
build:
context: ./
dockerfile: Dockerfile
target: reloader
args:
REACT_APP_ASSETS: http://localhost:3001
REACT_APP_STATION_ASSETS: http://localhost:3001
image: ghcr.io/terra-money/station:localhr
networks:
- default
ports:
- '3000:3000'
# To enable/disable hot reload in station
# comment/uncomment the build `target` above and
# comment/uncomment the following lines below
command: >
/bin/sh -c "
echo 'Development server will take 2-3min to start up.' && \
exec npm run start"
environment:
NODE_ENV: "development"
HTTPS: "false"
volumes:
- ./:/app/dev
- /app/dev/node_modules

###############################################################################

volumes:
terra:

networks:
default:
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"test": "react-scripts test",
"prepare": "husky install",
"pre-commit": "lint-staged",
"analyze": "source-map-explorer 'build/static/js/*.js'"
"analyze": "source-map-explorer 'build/static/js/*.js'",
"dc:up": "docker-compose up --build -d",
"dc:logs": "docker-compose logs -f",
"dc:down": "docker-compose down",
"dc:purge": "docker compose rm -f -s -v && docker volume rm localterra_terra"
},
"dependencies": {
"@amplitude/analytics-browser": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/app/InitNetworks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const InitNetworks = ({ children }: PropsWithChildren<{}>) => {
...networks.mainnet,
...networks.testnet,
...networks.classic,
...networks.localterra,
} ?? {}
).map((chain) => {
const lcd = customLCDs[chain?.chainID] ?? chain.lcd
Expand Down
7 changes: 5 additions & 2 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ export const LAZY_LIMIT = 999
export const BRIDGE = "https://walletconnect.terra.dev"

/* api */
export const ASSETS = "https://assets.terra.money"
export const STATION_ASSETS = "https://station-assets.terra.money"
export const ASSETS =
process.env.REACT_APP_ASSETS ?? "https://assets.terra.money"
export const STATION_ASSETS =
process.env.REACT_APP_STATION_ASSETS ?? "https://station-assets.terra.money"

export const OBSERVER = "wss://observer.terra.dev"

/* website */
Expand Down