feat: add env for docker-compose

This commit is contained in:
Innei
2021-10-02 14:03:28 +08:00
parent 9103863b6b
commit 9cef745dc8
8 changed files with 8 additions and 77 deletions

View File

@@ -5,8 +5,6 @@ on:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- master
paths:
- '.github/workflows/docker.yml'
- 'Dockerfile'

View File

@@ -4,6 +4,7 @@ services:
app:
container_name: mx-server
image: innei/mx-server:latest
command: node index.js --redis_host=redis --db_host=mongo --allowed_origins=${ALLOWED_ORIGINS} --jwt_secret=${JWT_SECRET}
restart: 'on-failure'
ports:
- '2333:2333'

View File

@@ -1,23 +1,3 @@
# This only for Debian based systems
# FROM node:16 as builder
# WORKDIR /app
# COPY . .
# RUN npm i -g pnpm
# RUN pnpm install
# RUN pnpm bundle
# FROM node:16
# ARG redis_host
# ARG mongo_host
# RUN apt update
# RUN apt install zip unzip mongo-tools -y
# WORKDIR /app
# COPY --from=builder /app/out .
# EXPOSE 2333
# CMD node index.js --redis_host=redis --db_host=mongo
# Use alpine to build smaller image
FROM node:16-alpine as builder
WORKDIR /app
COPY . .
@@ -35,4 +15,4 @@ WORKDIR /app
COPY --from=builder /app/out .
COPY --from=builder /app/assets ./assets
EXPOSE 2333
CMD node index.js --redis_host=redis --db_host=mongo
CMD echo "MixSpace Sever Image." && sh

View File

@@ -54,7 +54,6 @@
"dependencies": {
"@algolia/client-search": "*",
"@nestjs/common": "8.0.9",
"@nestjs/config": "1.0.1",
"@nestjs/core": "8.0.9",
"@nestjs/graphql": "9.0.5",
"@nestjs/jwt": "8.0.0",

36
pnpm-lock.yaml generated
View File

@@ -10,7 +10,6 @@ specifiers:
'@innei-util/prettier': latest
'@nestjs/cli': 8.1.2
'@nestjs/common': 8.0.9
'@nestjs/config': 1.0.1
'@nestjs/core': 8.0.9
'@nestjs/graphql': 9.0.5
'@nestjs/jwt': 8.0.0
@@ -110,7 +109,6 @@ specifiers:
dependencies:
'@algolia/client-search': 4.10.5
'@nestjs/common': 8.0.9_82ca6e21bd08a51a509883dd533f031a
'@nestjs/config': 1.0.1_946bf8982b6f3d7b46cf0b296973a2a3
'@nestjs/core': 8.0.9_52e70c4b6d0a880fc27d6b80ab23839a
'@nestjs/graphql': 9.0.5_29957df7d179923a6113f29796b4e4b7
'@nestjs/jwt': 8.0.0_@nestjs+common@8.0.9
@@ -1324,24 +1322,6 @@ packages:
- debug
dev: false
/@nestjs/config/1.0.1_946bf8982b6f3d7b46cf0b296973a2a3:
resolution: {integrity: sha512-azMl4uYlFIhYsywFxPJT81RxF3Pnn0TZW3EEmr0Wa0Wex8R2xpvBNrCcrOgW3TB1xGMP7eqBrlfsVh5ZP82szg==}
peerDependencies:
'@nestjs/common': ^7.0.0 || ^8.0.0
reflect-metadata: ^0.1.13
rxjs: ^6.0.0 || ^7.2.0
dependencies:
'@nestjs/common': 8.0.9_82ca6e21bd08a51a509883dd533f031a
dotenv: 10.0.0
dotenv-expand: 5.1.0
lodash.get: 4.4.2
lodash.has: 4.5.2
lodash.set: 4.3.2
reflect-metadata: 0.1.13
rxjs: 7.3.1
uuid: 8.3.2
dev: false
/@nestjs/core/8.0.9_52e70c4b6d0a880fc27d6b80ab23839a:
resolution: {integrity: sha512-Q8bge+yuFzcuW9iY5fiMz3gydyB3D25dO9/YFGEtHexw2ipQA1QCt94XfIxGqFe1C07k5IDSK/C/l+R33CHrGg==}
requiresBuild: true
@@ -3681,10 +3661,6 @@ packages:
is-obj: 2.0.0
dev: false
/dotenv-expand/5.1.0:
resolution: {integrity: sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==}
dev: false
/dotenv/10.0.0:
resolution: {integrity: sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==}
engines: {node: '>=10'}
@@ -6095,14 +6071,6 @@ packages:
/lodash.flatten/4.4.0:
resolution: {integrity: sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=}
/lodash.get/4.4.2:
resolution: {integrity: sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=}
dev: false
/lodash.has/4.5.2:
resolution: {integrity: sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=}
dev: false
/lodash.includes/4.3.0:
resolution: {integrity: sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=}
dev: false
@@ -6138,10 +6106,6 @@ packages:
resolution: {integrity: sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=}
dev: false
/lodash.set/4.3.2:
resolution: {integrity: sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=}
dev: false
/lodash.sortby/4.7.0:
resolution: {integrity: sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=}
dev: false

View File

@@ -11,7 +11,7 @@ console.log(argv)
exports.API_VERSION = 2
exports.CROSS_DOMAIN = {
allowedOrigins: argv.allowedOrigins
allowedOrigins: argv.allowed_origins
? argv.allowedOrigins?.split?.(',')
: [
'innei.ren',
@@ -45,7 +45,7 @@ exports.REDIS = {
httpCacheTTL: 5,
max: 5,
disableApiCache:
(isDev || argv.disableCache) && !process.env['ENABLE_CACHE_DEBUG'],
(isDev || argv.disable_cache) && !process.env['ENABLE_CACHE_DEBUG'],
}
/**
@@ -56,8 +56,8 @@ exports.AXIOS_CONFIG = {
}
exports.SECURITY = {
jwtSecret: argv.jwtSecret || 'asjhczxiucipoiopiqm2376',
jwtSecret: argv.jwt_secret || argv.jwtSecret || 'asjhczxiucipoiopiqm2376',
jwtExpire: '7d',
// 跳过登陆鉴权
skipAuth: argv.skipAuth ?? false,
skipAuth: !isDev ? true : argv.skip_auth ?? false,
}

View File

@@ -1,5 +1,4 @@
import { Logger, MiddlewareConsumer, Module, NestModule } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'
import { GraphQLModule } from '@nestjs/graphql'
import { mkdirSync } from 'fs'
@@ -67,16 +66,7 @@ mkdirs()
imports: [
DbModule,
CacheModule,
ConfigModule.forRoot({
envFilePath: [
'.env.development.local',
'.env.development',
'.env.production.local',
'.env.production',
'.env',
],
isGlobal: true,
}),
GraphQLModule.forRoot({
debug: isDev,
playground: isDev,

View File

@@ -7,8 +7,7 @@ import { AuthController } from './auth.controller'
import { AuthService } from './auth.service'
import { JwtStrategy } from './jwt.strategy'
export const __secret: any =
SECURITY.jwtSecret || process.env.SECRET || 'asjhczxiucipoiopiqm2376'
export const __secret: any = SECURITY.jwtSecret || 'asjhczxiucipoiopiqm2376'
const jwtModule = JwtModule.registerAsync({
useFactory() {