Skip to content
Permalink
Browse files

feat: add docker / docker-compose (WIP)

  • Loading branch information...
evereq committed Jun 26, 2019
1 parent a816d6f commit a25492cffa4757dd764b5a712a1bdfde2cc1c93f
@@ -0,0 +1,43 @@
# API

FROM node:alpine

RUN apk update

RUN npm i -g npm

RUN apk add libexecinfo libexecinfo-dev

RUN apk --no-cache add --virtual builds-deps build-base \
snappy g++ snappy-dev gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \
npm install --quiet node-gyp -g

RUN npm config set python /usr/bin/python

RUN npm install yarn -g

RUN npm install pm2 -g --unsafe-perm

# Make our app folder (empty for now)
RUN mkdir -p /usr/src/app

# Provides cached layer for node_modules and bower_components
ADD package.json /tmp/package.json
ADD apps/api/package.json /tmp/apps/api/package.json
# COPY .snyk /tmp/.snyk
COPY yarn.lock /tmp/yarn.lock
RUN cd /tmp/ && yarn install
RUN cp -a /tmp/node_modules /usr/src/app/
RUN cd /usr/src/app

WORKDIR /usr/src/app

# Bundle app source
ADD . /usr/src/app

EXPOSE 3000

ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait
RUN chmod +x /wait

CMD /wait && yarn run api:seedData && yarn run start:api:prod
No changes.
@@ -0,0 +1,23 @@
events {
worker_connections 1024;
}

http {

error_log /etc/nginx/error.log warn;
client_max_body_size 20m;

upstream webapp {
server webapp:4200;
}

server {
server_name gauzy.dev;

location / {
proxy_pass http://webapp;
}

listen 8080;
}
}
@@ -0,0 +1,42 @@
# Webapp

FROM node:alpine

RUN apk update

RUN npm i -g npm

RUN apk add libexecinfo libexecinfo-dev

RUN apk --no-cache add --virtual builds-deps build-base \
snappy g++ snappy-dev gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \
npm install --quiet node-gyp -g

RUN npm config set python /usr/bin/python

RUN npm install yarn -g

RUN npm install pm2 -g --unsafe-perm

# Make our app folder (empty for now)
RUN mkdir -p /usr/src/app

# Provides cached layer for node_modules and bower_components
ADD package.json /tmp/package.json
# COPY .snyk /tmp/.snyk
COPY yarn.lock /tmp/yarn.lock
RUN cd /tmp/ && yarn install
RUN cp -a /tmp/node_modules /usr/src/app/
RUN cd /usr/src/app

WORKDIR /usr/src/app

# Bundle app source
ADD . /usr/src/app

EXPOSE 4200

ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait
RUN chmod +x /wait

CMD /wait && yarn run start:gauzy:prod
@@ -0,0 +1,28 @@
dist
tmp
.github
.npmrc
.travis.yml
greenkeeper.json
docker-compose.yml
*.md
.deploy
.git/
.gitignore
node_modules

# IDEs and editors
.idea
.vscode
.project
.classpath
*.launch
.settings/

# e2e
e2e/*.js
e2e/*.map

#System Files
.DS_Store
Thumbs.db
@@ -7,7 +7,7 @@

# dependencies
/node_modules

/apps/api/node_modules
# IDEs and editors
/.idea
.project
@@ -93,7 +93,8 @@
},
"configurations": {
"production": {
"browserTarget": "gauzy:build:production"
"browserTarget": "gauzy:build:production",
"proxyConfig": "apps/gauzy/proxy.prod.conf.json"
}
}
},

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -4,16 +4,17 @@
"description": "Gauzy API",
"license": "AGPL-3.0",
"scripts": {
"typeorm": "ts-node -r tsconfig-paths/register --project apps/api/tsconfig.app.json node_modules/.bin/typeorm",
"typeorm:sync": "typeorm schema:sync",
"typeorm:seeds": "typeorm migration:run",
"typeorm:flush": "typeorm migration:revert",
"typeorm:create": "typeorm migration:create",
"typeorm": "yarn ts-node -r tsconfig-paths/register --project apps/api/tsconfig.app.json node_modules/.bin/typeorm",
"typeorm:sync": "yarn typeorm schema:sync",
"typeorm:seeds": "yarn typeorm migration:run",
"typeorm:flush": "yarn typeorm migration:revert",
"typeorm:create": "yarn typeorm migration:create",
"typeorm:preserve": "yarn typeorm:sync -- -f=ormconfig && yarn typeorm:seeds -- -f=ormconfig",
"start": "ts-node -r tsconfig-paths/register --project apps/api/tsconfig.app.json src/main.ts",
"build": "ng build api",
"build:prod": "ng build api --prod",
"seedData": "ts-node -r tsconfig-paths/register --project tsconfig.app.json src/app/core/seeds/index.ts"
"start": "yarn ts-node -r tsconfig-paths/register --project apps/api/tsconfig.app.json src/main.ts",
"build": "yarn ng build api",
"build:prod": "yarn ng build api --prod",
"seedData": "yarn ts-node -r tsconfig-paths/register --project tsconfig.app.json src/app/core/seeds/index.ts",
"seedData:prod": "yarn ts-node -r tsconfig-paths/register --project tsconfig.app.json src/app/core/seeds/index.ts -c=production"
},
"dependencies": {
"@nestjs/common": "^6.3.1",
@@ -18,7 +18,12 @@ export class ConfigService {
for (const [key, value] of Object.entries(environment.env)) {
process.env[key] = value;
}
console.log('is prod? ', environment.production);

this.logger.log('Is Production: ' + environment.production);

if (packageJson) {
this.logger.log('Package.json version: ' + packageJson.version)
}
}

get(key: keyof IEnvironment): IEnvironment[keyof IEnvironment] {
@@ -27,8 +32,11 @@ export class ConfigService {

getVersion(): string {
if (!process.env.APP_VERSION) {
process.env.APP_VERSION = packageJson.version;
if (packageJson && packageJson.version) {
process.env.APP_VERSION = packageJson.version;
}
}

return process.env.APP_VERSION;
}

@@ -1,3 +1,27 @@
export const environment = {
production: true
import { IEnvironment } from './ienvironment';

export const environment : IEnvironment = {
production: true,
envName: 'prod',
env: {
LOG_LEVEL: 'debug'
},
USER_PASSWORD_BCRYPT_SALT_ROUNDS: 12,
JWT_SECRET: 'secretKey',
database: {
type: 'postgres',
host: 'db',
port: 5432,
database: 'postgres',
username: 'postgres',
password: 'root',
keepConnectionAlive: true,
logging: true,
synchronize: true,
uuidExtension: 'pgcrypto',
},
defaultAdmin: {
email: 'admin@ever.co',
password: "admin"
}
};
@@ -0,0 +1,6 @@
{
"/api": {
"target": "http://api:3000",
"secure": false
}
}

0 comments on commit a25492c

Please sign in to comment.
You can’t perform that action at this time.