-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from meta-d/develop
Merge the init status from develop
- Loading branch information
Showing
121 changed files
with
2,950 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
ARG HOST | ||
ARG PORT | ||
|
||
FROM node:18-alpine AS build | ||
|
||
LABEL maintainer="meta.digital.cloud@gmail.com" | ||
|
||
ENV CI=true | ||
|
||
RUN apk --update add bash && \ | ||
apk add --no-cache --virtual build-dependencies dos2unix gcc g++ git make python3 vips-dev && \ | ||
mkdir /srv/pangolin && chown -R node:node /srv/pangolin | ||
|
||
WORKDIR /srv/pangolin | ||
|
||
COPY --chown=node:node packages/store/package.json ./packages/store/ | ||
COPY --chown=node:node packages/core/package.json ./packages/core/ | ||
COPY --chown=node:node packages/contracts/package.json ./packages/contracts/ | ||
COPY --chown=node:node packages/common/package.json ./packages/common/ | ||
COPY --chown=node:node packages/config/package.json ./packages/config/ | ||
COPY --chown=node:node packages/auth/package.json ./packages/auth/ | ||
COPY --chown=node:node packages/server/package.json ./packages/server/ | ||
COPY --chown=node:node packages/adapter/package.json ./packages/adapter/ | ||
COPY --chown=node:node packages/analytics/package.json ./packages/analytics/ | ||
|
||
COPY --chown=node:node .deploy/api/package.json ./ | ||
|
||
RUN yarn install && yarn cache clean | ||
|
||
COPY --chown=node:node nx.json ./ | ||
COPY --chown=node:node tsconfig.base.json ./ | ||
COPY --chown=node:node packages ./packages | ||
COPY --chown=node:node apps/api ./apps/api | ||
RUN yarn nx build api | ||
|
||
#//////////////////////////////////////////////////////////////////////////////// | ||
FROM node:18-alpine AS production | ||
|
||
ENV NODE_OPTIONS=${NODE_OPTIONS:-"--max-old-space-size=2048"} \ | ||
NODE_ENV=${NODE_ENV:-production} \ | ||
API_HOST=${API_HOST:-api} \ | ||
API_PORT=${API_PORT:-3000} \ | ||
API_BASE_URL=${API_BASE_URL:-http://localhost:3000} \ | ||
SENTRY_DSN=${SENTRY_DSN} \ | ||
DB_HOST=${DB_HOST:-db} \ | ||
DB_NAME=${DB_NAME:-postgres} \ | ||
DB_PORT=${DB_PORT:-5432} \ | ||
DB_USER=${DB_USER} \ | ||
DB_PASS=${DB_PASS} \ | ||
DB_TYPE=${DB_TYPE:-sqlite} \ | ||
DB_SSL_MODE=${DB_SSL_MODE} \ | ||
HOST=${HOST:-0.0.0.0} \ | ||
PORT=${PORT:-3000} \ | ||
DEMO=${DEMO:-false} | ||
|
||
WORKDIR /srv/pangolin | ||
|
||
RUN npm install pm2 -g | ||
|
||
# COPY dist and dependencies | ||
COPY --chown=node:node --from=build /srv/pangolin/dist/packages ./packages | ||
COPY --chown=node:node --from=build /srv/pangolin/dist/apps/api . | ||
COPY --chown=node:node --from=build /srv/pangolin/tsconfig.base.json ./ | ||
COPY --chown=node:node --from=build /srv/pangolin/yarn.lock . | ||
COPY --chown=node:node .deploy/api/package-prod.json ./package.json | ||
|
||
RUN yarn config set network-timeout 300000 | ||
RUN yarn install --frozen-lockfile && yarn cache clean && \ | ||
touch ormlogs.log && chown node:node ormlogs.log | ||
|
||
USER node:node | ||
|
||
EXPOSE ${PORT} | ||
|
||
CMD [ "pm2-runtime", "main.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
# This Entrypoint used inside Docker Compose only | ||
|
||
export WAIT_HOSTS=$DB_HOST:$DB_PORT | ||
|
||
# in Docker Compose we should wait other services start | ||
./wait | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
# This Entrypoint used when we run Docker container outside of Docker Compose (e.g. in k8s) | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "metad-server", | ||
"version": "1.6.1", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "nx serve", | ||
"build": "nx build", | ||
"test": "nx test", | ||
"build:all": "yarn rimraf dist && yarn nx build contracts && yarn nx build common && yarn nx build config && yarn nx build auth && yarn nx build server && yarn nx build adapter && yarn nx build analytics && yarn nx build api" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"@nestjs/common": "^8.0.0", | ||
"@nestjs/core": "^8.0.0", | ||
"@nestjs/platform-express": "^8.0.0", | ||
"@swc/helpers": "~0.5.0", | ||
"idb-keyval": "^6.0.2", | ||
"money-clip": "^3.0.5", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.0.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
}, | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "ocap-server", | ||
"author": "Metad", | ||
"version": "0.4.0-rc.1", | ||
"scripts": { | ||
"start": "nx serve", | ||
"build": "nx build", | ||
"test": "nx test", | ||
"build:all": "yarn rimraf dist && yarn nx build contracts && yarn nx build common && yarn nx build config && yarn nx build auth && yarn nx build server && yarn nx build adapter && yarn nx build analytics && yarn nx build api" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"@nestjs/common": "^8.0.0", | ||
"@nestjs/core": "^8.0.0", | ||
"@nestjs/platform-express": "^8.0.0", | ||
"@swc/helpers": "~0.5.0", | ||
"idb-keyval": "^6.0.2", | ||
"money-clip": "^3.0.5", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.0.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/schematics": "^10.0.1", | ||
"@nestjs/testing": "^10.0.2", | ||
"@nx/eslint-plugin": "16.6.0", | ||
"@nx/jest": "16.6.0", | ||
"@nx/js": "16.6.0", | ||
"@nx/linter": "16.6.0", | ||
"@nx/nest": "16.6.0", | ||
"@nx/node": "16.6.0", | ||
"@nx/rollup": "16.6.0", | ||
"@nx/web": "16.6.0", | ||
"@nx/webpack": "16.6.0", | ||
"@nx/workspace": "16.6.0", | ||
"@swc/cli": "~0.1.62", | ||
"@swc/core": "~1.3.51", | ||
"@swc/jest": "0.2.20", | ||
"@types/jest": "29.4.4", | ||
"@types/node": "18.7.1", | ||
"@typescript-eslint/eslint-plugin": "5.62.0", | ||
"@typescript-eslint/parser": "5.62.0", | ||
"eslint": "8.15.0", | ||
"eslint-config-prettier": "8.1.0", | ||
"jest": "29.4.3", | ||
"nx": "16.6.0", | ||
"ts-jest": "29.1.1", | ||
"ts-node": "10.9.1", | ||
"typescript": "5.1.3" | ||
}, | ||
"workspaces": [ | ||
"apps/*", | ||
"packages/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG OLAP_VERSION | ||
ARG REDIS_HOST | ||
ARG REDIS_PORT | ||
ARG REDIS_PASSWORD | ||
ARG REDIS_DATABASE | ||
|
||
# ==================================================== Stage ==========================================================# | ||
FROM maven:3.8-openjdk-11 AS build | ||
|
||
WORKDIR /app | ||
|
||
COPY .deploy/olap/settings.xml /usr/share/maven/ref/ | ||
COPY packages/olap/pom.xml ./pom.xml | ||
RUN mvn -B -s /usr/share/maven/ref/settings.xml dependency:resolve | ||
|
||
COPY packages/olap/src ./src | ||
RUN mvn -B -s /usr/share/maven/ref/settings.xml clean install | ||
|
||
# ==================================================== Stage ==========================================================# | ||
FROM adoptopenjdk:11-jre-hotspot AS webapp | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app/target/olap-0.0.1-SNAPSHOT.jar /app/app.jar | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java", "-jar", "/app/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
https://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
<localRepository>/usr/share/maven/ref/repository</localRepository> | ||
<mirrors> | ||
|
||
<mirror> | ||
<id>huaweicloud</id> | ||
<mirrorOf>central</mirrorOf> | ||
<url>https://mirrors.huaweicloud.com/repository/maven/</url> | ||
</mirror> | ||
|
||
<mirror> | ||
<id>aliyunmaven</id> | ||
<mirrorOf>central</mirrorOf> | ||
<name>阿里云公共仓库</name> | ||
<url>https://maven.aliyun.com/repository/central</url> | ||
</mirror> | ||
<mirror> | ||
<id>repo1</id> | ||
<mirrorOf>central</mirrorOf> | ||
<name>central repo</name> | ||
<url>https://repo1.maven.org/maven2/</url> | ||
</mirror> | ||
<mirror> | ||
<id>aliyunmaven</id> | ||
<mirrorOf>apache snapshots</mirrorOf> | ||
<name>阿里云阿帕奇仓库</name> | ||
<url>https://maven.aliyun.com/repository/apache-snapshots</url> | ||
</mirror> | ||
</mirrors> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
ARG NODE_OPTIONS | ||
ARG NODE_ENV | ||
ARG API_BASE_URL | ||
ARG API_HOST | ||
ARG API_PORT | ||
ARG SENTRY_DSN | ||
ARG DB_HOST | ||
ARG DB_NAME | ||
ARG DB_PORT | ||
ARG DB_USER | ||
ARG DB_PASS | ||
ARG DB_TYPE | ||
ARG DB_SSL_MODE | ||
ARG DEMO | ||
ARG HOST | ||
ARG PORT | ||
|
||
# ==================================================== Stage ==========================================================# | ||
# Copy package.json, Install npm dependencies and Build | ||
FROM node:18-alpine AS build | ||
|
||
LABEL maintainer="meta.digital.cloud@gmail.com" | ||
|
||
ENV CI=true | ||
|
||
RUN apk --update add bash && \ | ||
apk add --no-cache --virtual build-dependencies dos2unix gcc g++ git make python3 vips-dev && \ | ||
mkdir /srv/pangolin && chown -R node:node /srv/pangolin | ||
|
||
COPY wait .deploy/api/entrypoint.prod.sh .deploy/api/entrypoint.compose.sh / | ||
RUN chmod +x /wait /entrypoint.compose.sh /entrypoint.prod.sh && dos2unix /entrypoint.prod.sh && dos2unix /entrypoint.compose.sh | ||
|
||
WORKDIR /srv/pangolin | ||
|
||
COPY --chown=node:node packages/contracts/package.json ./packages/contracts/ | ||
|
||
RUN yarn config set network-timeout 300000 | ||
|
||
COPY --chown=node:node .deploy/webapp/package.json ./package.json | ||
RUN yarn install | ||
|
||
COPY nx.json ./ | ||
COPY tsconfig.base.json ./ | ||
COPY packages ./packages | ||
COPY libs ./libs | ||
COPY apps/cloud ./apps/cloud | ||
|
||
RUN yarn build:cloud:prod | ||
|
||
# ==================================================== Stage ==========================================================# | ||
FROM nginx:alpine AS production | ||
|
||
ENV API_BASE_URL=${API_BASE_URL:-http://localhost:3000} \ | ||
HOST=${HOST:-0.0.0.0} \ | ||
PORT=${PORT:-4200} \ | ||
DEMO=${DEMO:-false} | ||
|
||
WORKDIR /srv/pangolin | ||
|
||
COPY --chown=nginx:nginx --from=build /wait ./ | ||
COPY --chown=nginx:nginx .deploy/webapp/entrypoint.compose.sh ./ | ||
COPY --chown=nginx:nginx .deploy/webapp/entrypoint.prod.sh ./ | ||
COPY --chown=nginx:nginx .deploy/webapp/nginx.compose.conf /etc/nginx/conf.d/compose.conf.template | ||
COPY --chown=nginx:nginx .deploy/webapp/nginx.prod.conf /etc/nginx/conf.d/prod.conf.template | ||
COPY --chown=nginx:nginx --from=build /srv/pangolin/dist/apps/cloud . | ||
|
||
RUN chmod +x wait entrypoint.compose.sh entrypoint.prod.sh && \ | ||
chmod a+rw /etc/nginx/conf.d/compose.conf.template /etc/nginx/conf.d/prod.conf.template | ||
|
||
EXPOSE 4200 | ||
|
||
ENTRYPOINT [ "sh", "./entrypoint.prod.sh" ] | ||
|
||
CMD [ "nginx", "-g", "daemon off;" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
# This Entrypoint used inside Docker Compose only | ||
|
||
export WAIT_HOSTS=$API_HOST:$API_PORT | ||
|
||
# In production we should replace some values in generated JS code | ||
sed -i "s#DOCKER_API_BASE_URL#$API_BASE_URL#g" *.js | ||
sed -i "s#DOCKER_CLIENT_BASE_URL#$CLIENT_BASE_URL#g" *.js | ||
sed -i "s#DOCKER_SENTRY_DSN#$SENTRY_DSN#g" *.js | ||
sed -i "s#DOCKER_CLOUDINARY_CLOUD_NAME#$CLOUDINARY_CLOUD_NAME#g" *.js | ||
sed -i "s#DOCKER_CLOUDINARY_API_KEY#$CLOUDINARY_API_KEY#g" *.js | ||
sed -i "s#DOCKER_GOOGLE_MAPS_API_KEY#$GOOGLE_MAPS_API_KEY#g" *.js | ||
sed -i "s#DOCKER_GOOGLE_PLACE_AUTOCOMPLETE#$GOOGLE_PLACE_AUTOCOMPLETE#g" *.js | ||
sed -i "s#DOCKER_DEFAULT_LATITUDE#$DEFAULT_LATITUDE#g" *.js | ||
sed -i "s#DOCKER_DEFAULT_LONGITUDE#$DEFAULT_LONGITUDE#g" *.js | ||
sed -i "s#DOCKER_DEFAULT_CURRENCY#$DEFAULT_CURRENCY#g" *.js | ||
sed -i "s#DOCKER_CHATWOOT_SDK_TOKEN#$CHATWOOT_SDK_TOKEN#g" *.js | ||
sed -i "s#DOCKER_DEMO#$DEMO#g" *.js | ||
|
||
envsubst '${API_HOST} ${API_PORT}' < /etc/nginx/conf.d/compose.conf.template > /etc/nginx/nginx.conf | ||
|
||
# In Docker Compose we should wait other services start | ||
./wait | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
# This Entrypoint used when we run Docker container outside of Docker Compose (e.g. in k8s) | ||
|
||
# In production we should replace some values in generated JS code | ||
sed -i "s#DOCKER_API_BASE_URL#$API_BASE_URL#g" *.js | ||
sed -i "s#DOCKER_CLIENT_BASE_URL#$CLIENT_BASE_URL#g" *.js | ||
sed -i "s#DOCKER_SENTRY_DSN#$SENTRY_DSN#g" *.js | ||
sed -i "s#DOCKER_CLOUDINARY_CLOUD_NAME#$CLOUDINARY_CLOUD_NAME#g" *.js | ||
sed -i "s#DOCKER_CLOUDINARY_API_KEY#$CLOUDINARY_API_KEY#g" *.js | ||
sed -i "s#DOCKER_GOOGLE_MAPS_API_KEY#$GOOGLE_MAPS_API_KEY#g" *.js | ||
sed -i "s#DOCKER_GOOGLE_PLACE_AUTOCOMPLETE#$GOOGLE_PLACE_AUTOCOMPLETE#g" *.js | ||
sed -i "s#DOCKER_DEFAULT_LATITUDE#$DEFAULT_LATITUDE#g" *.js | ||
sed -i "s#DOCKER_DEFAULT_LONGITUDE#$DEFAULT_LONGITUDE#g" *.js | ||
sed -i "s#DOCKER_DEFAULT_CURRENCY#$DEFAULT_CURRENCY#g" *.js | ||
sed -i "s#DOCKER_CHATWOOT_SDK_TOKEN#$CHATWOOT_SDK_TOKEN#g" *.js | ||
sed -i "s#DOCKER_DEMO#$DEMO#g" *.js | ||
|
||
# We may not need to use that env vars now in nginx.config, but we may want later. | ||
# Also we just need to copy nginx.conf to correct place anyway... | ||
envsubst '' < /etc/nginx/conf.d/prod.conf.template > /etc/nginx/nginx.conf | ||
|
||
exec "$@" |
Oops, something went wrong.