Skip to content

Commit

Permalink
chore: improve docker compose setup
Browse files Browse the repository at this point in the history
ref #229
  • Loading branch information
ygrishajev committed Jun 17, 2024
1 parent a827643 commit 98fd072
Show file tree
Hide file tree
Showing 32 changed files with 188 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.deploy-web == 'true'
run: docker build -f docker/Dockerfile.deploy-web -t console-deploy-web .
run: npm run dc:build -- deploy-web
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.indexer == 'true'
run: docker build -f docker/Dockerfile.indexer -t console-indexer .
run: npm run dc:build -- indexer
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-landing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image for LANDING
if: steps.filter.outputs.landing == 'true'
run: docker build -f docker/Dockerfile.landing -t console-landing .
run: npm run dc:build -- landing
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-provider-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.provider-proxy == 'true'
run: docker build -f docker/Dockerfile.provider-proxy -t console-provider-proxy .
run: npm run dc:build -- provider-proxy
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-stats-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build the Docker image
if: steps.filter.outputs.stats-web == 'true'
run: docker build -f docker/Dockerfile.stats-web -t console-stats-web .
run: npm run dc:build -- stats-web
2 changes: 1 addition & 1 deletion .github/workflows/validate-n-build-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:

- name: Build the Docker image for API
if: steps.filter.outputs.api == 'true'
run: docker build -f docker/Dockerfile.api -t console-api .
run: npm run dc:build -- api
2 changes: 0 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@octokit/rest": "^18.12.0",
"@sentry/node": "^7.55.2",
"axios": "^0.27.2",
"bufferutil": "^4.0.8",
"cosmjs-types": "^0.5.0",
"date-fns": "^2.29.2",
"date-fns-tz": "^1.3.6",
Expand All @@ -60,7 +59,6 @@
"sequelize": "^6.21.3",
"sequelize-typescript": "^2.1.5",
"stripe": "^10.14.0",
"utf-8-validate": "^5.0.10",
"uuid": "^9.0.1",
"zod": "^3.22.4"
},
Expand Down
6 changes: 3 additions & 3 deletions apps/api/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require("path");
const { NODE_ENV = "development" } = process.env;
const NodemonPlugin = require("nodemon-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const hq = require("alias-hq");
const webpack = require("webpack");

const { NODE_ENV = "development" } = process.env;

module.exports = {
entry: "./src/index.ts",
mode: NODE_ENV,
Expand All @@ -24,8 +25,7 @@ module.exports = {
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: "ts-loader",
options: { configFile: "tsconfig.json" }
loader: "ts-loader"
}
]
},
Expand Down
11 changes: 7 additions & 4 deletions apps/api/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const path = require("path");
const { NODE_ENV = "production" } = process.env;
const webpack = require("webpack");
const nodeExternals = require("webpack-node-externals");
const hq = require("alias-hq");
const webpack = require("webpack");

const { NODE_ENV = "production" } = process.env;

module.exports = {
entry: "./src/index.ts",
Expand All @@ -22,11 +23,13 @@ module.exports = {
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: "ts-loader",
options: { configFile: "tsconfig.json" }
loader: "ts-loader"
}
]
},
optimization: {
minimize: false
},
plugins: [new webpack.IgnorePlugin({ resourceRegExp: /^pg-native$/ })],
node: {
__dirname: true
Expand Down
34 changes: 0 additions & 34 deletions apps/deploy-web/nginx.conf

This file was deleted.

1 change: 0 additions & 1 deletion apps/deploy-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.3",
"eslint-plugin-simple-import-sort": "^12.1.0",
"patch-package": "^8.0.0",
"postcss": "^8.4.31",
"postcss-nesting": "^12.0.2",
"prettier": "^3.3.0",
Expand Down
1 change: 0 additions & 1 deletion apps/deploy-web/patches/placeholder.txt

This file was deleted.

4 changes: 3 additions & 1 deletion apps/indexer/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const path = require("path");
const { NODE_ENV = "development" } = process.env;
const NodemonPlugin = require("nodemon-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const hq = require("alias-hq");
const webpack = require("webpack");

const { NODE_ENV = "development" } = process.env;

module.exports = {
entry: "./src/index.ts",
mode: NODE_ENV,
target: "node",
devtool: "source-map",
output: {
path: path.resolve(__dirname, "dist"),
filename: "server.js"
Expand Down
3 changes: 2 additions & 1 deletion apps/indexer/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const path = require("path");
const { NODE_ENV = "production" } = process.env;
const webpack = require("webpack");
const nodeExternals = require("webpack-node-externals");
const hq = require("alias-hq");

const { NODE_ENV = "production" } = process.env;

module.exports = {
entry: "./src/index.ts",
mode: NODE_ENV,
Expand Down
3 changes: 2 additions & 1 deletion apps/provider-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "npx tsc",
"format": "prettier --write ./*.{ts,js,json} **/*.{ts,js,json}",
"lint": "eslint .",
"start": "npx tsc && node ./build/main.js"
"start": "npm run build && node ./dist/server.js",
"dev": "npm run start"
},
"dependencies": {
"axios": "^1.3.0",
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions apps/provider-proxy/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"compilerOptions": {
"outDir": "build",
},
"extends": "@akashnetwork/dev-config/tsconfig.base-node.json"
}
5 changes: 4 additions & 1 deletion apps/provider-proxy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"compilerOptions": {
"outDir": "dist",
},
"exclude": [
"node_modules",
"build"
"dist"
],
"extends": "./tsconfig.build.json"
}
31 changes: 25 additions & 6 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
services:
api:
image: console-api:${API_TAG:-latest}
build:
dockerfile: docker/Dockerfile.api
dockerfile: docker/Dockerfile.node
target: production
args:
WORKSPACE: apps/api

indexer:
image: console-indexer:${INDEXER_TAG:-latest}
build:
dockerfile: docker/Dockerfile.indexer
dockerfile: docker/Dockerfile.node
target: production
args:
WORKSPACE: apps/indexer

provider-proxy:
image: console-provider-proxy:${PROVIDER_PROXY_TAG:-latest}
build:
dockerfile: docker/Dockerfile.provider-proxy
dockerfile: docker/Dockerfile.node
target: production
args:
WORKSPACE: apps/provider-proxy

deploy-web:
image: console-deploy-web:${DEPLOY_WEB_TAG:-latest}
build:
dockerfile: docker/Dockerfile.deploy-web
dockerfile: docker/Dockerfile.nextjs
target: production
args:
WORKSPACE: apps/deploy-web

stats-web:
image: console-stats-web:${STATS_WEB_TAG:-latest}
build:
dockerfile: docker/Dockerfile.stats-web
dockerfile: docker/Dockerfile.nextjs
args:
WORKSPACE: apps/stats-web

landing:
image: console-landing:${LANDING_TAG:-latest}
build:
dockerfile: docker/Dockerfile.landing
dockerfile: docker/Dockerfile.nextjs
args:
WORKSPACE: apps/landing
21 changes: 16 additions & 5 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,36 @@ services:
restart: always
env_file:
- .env.sandbox.docker-compose-dev
environment:
PORT: 3000
ports:
- '3080:3080'
- '3080:3000'
depends_on:
- db
db:
condition: service_healthy

indexer:
restart: always
env_file:
- .env.sandbox.docker-compose-dev
depends_on:
- db
db:
condition: service_healthy

provider-proxy:
restart: always
environment:
PORT: 3000
ports:
- '3040:3040'
- '3040:3000'

deploy-web:
restart: always
environment:
API_BASE_URL: http://api:3080
PROVIDER_PROXY_URL: http://provider-proxy:3040
env_file:
- apps/deploy-web/.env.local
- .env.sandbox.docker-compose-dev
ports:
- '3000:3000'
depends_on:
Expand Down Expand Up @@ -58,6 +64,11 @@ services:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "bash", "/usr/local/bin/check-init.sh"]
interval: 10s
timeout: 5s
retries: 20

volumes:
postgres_data:
Expand Down
32 changes: 0 additions & 32 deletions docker/Dockerfile.api

This file was deleted.

3 changes: 2 additions & 1 deletion docker/Dockerfile.db
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FROM postgres:14.9

RUN apt-get update && apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*
COPY prepare-and-seed-db.sh /docker-entrypoint-initdb.d/
COPY bin/check-postgres-init.sh /usr/local/bin/check-init.sh
COPY bin/prepare-and-seed-postgres.sh /docker-entrypoint-initdb.d/
Loading

0 comments on commit 98fd072

Please sign in to comment.