-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to handle production enviroments
- Loading branch information
Showing
13 changed files
with
118 additions
and
89 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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
DOCKERHUB_NAME=your_docker_username | ||
IMAGE_NAME=image_name | ||
IMAGE_VERSION=0.0.0 | ||
# Container version | ||
DOCKERHUB_NAME=name | ||
IMAGE_NAME=docker-deploy-demo | ||
IMAGE_VERSION=0.0.1 | ||
|
||
EXPRESS_CONTAINER_PORT=8080 | ||
# Container runtime | ||
PORT=8080 | ||
EXPRESS_HOST_PORT=8080 | ||
EXPRESS_CONTAINER_PORT=8080 | ||
|
||
POSTGRES_HOST_PORT=5432 | ||
POSTGRES_CONTAINER_PORT=5432 | ||
POSTGRES_HOSTNAME=postgres-primary-db | ||
POSTGRES_USER=postgres_user | ||
POSTGRES_USER=username | ||
POSTGRES_PASSWORD=password | ||
POSTGRES_DB=project_db | ||
POSTGRES_DB=database_name | ||
|
||
REDIS_HOSTNAME=redis://redis-server:6379 | ||
REDIS_HOST_PORT=6379 | ||
REDIS_CONTAINER_PORT=6379 | ||
SESSION_SECRET=secret |
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 |
---|---|---|
@@ -1,21 +1,36 @@ | ||
# Built from Node latest Alpine | ||
FROM node:10.0 | ||
FROM node:10.15.1-alpine | ||
|
||
# Specify an optional argument with a default value | ||
ARG app_directory=/src/app | ||
ARG NODE_ENV=development | ||
# Update latest security patches | ||
RUN apk update && apk upgrade | ||
|
||
# Set the app directory as the context for all commands and entry to the container | ||
WORKDIR ${app_directory} | ||
# RUN adduser webuser - | ||
RUN adduser -D -g '' webuser | ||
|
||
# ONLY copy over the package.json to install NPM packages | ||
# SET default APP_DIR path | ||
ARG APP_DIR=/src/app | ||
|
||
# Create APP_DIR path and set permissions | ||
|
||
RUN mkdir -p $APP_DIR | ||
RUN chown -R webuser:webuser $APP_DIR | ||
|
||
# Switch user to non-privileged user | ||
USER webuser | ||
|
||
# Change working directory to application directory | ||
WORKDIR $APP_DIR | ||
|
||
# Copy package.json to /app directory | ||
COPY package.json . | ||
|
||
# Install node module dependencies | ||
# Install node modules/dependencies | ||
RUN npm install | ||
|
||
# Add the rest of the project files(most builds will start from here based on cache) | ||
# Copy application code | ||
COPY . . | ||
|
||
# Start the node application as you normally would | ||
# Expose this port on DOCKER NETWORK (NOT HOST MAPPING) | ||
EXPOSE 8080 | ||
|
||
# Start the Express server | ||
CMD ["node", "./server/server.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
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,38 @@ | ||
version: "3" | ||
services: | ||
express-server: | ||
image: ${DOCKERHUB_NAME}/${IMAGE_NAME}:${IMAGE_VERSION} | ||
depends_on: | ||
- postgres-primary-db | ||
container_name: ${IMAGE_NAME} | ||
env_file: .env | ||
environment: | ||
ENVIRONMENT: production | ||
NODE_ENV: production | ||
ports: | ||
- "${EXPRESS_HOST_PORT}:${EXPRESS_CONTAINER_PORT}" | ||
networks: | ||
- my-app-network | ||
postgres-primary-db: | ||
image: postgres:10.0-alpine | ||
env_file: .env | ||
volumes: | ||
- pg-data-volume:/var/lib/postgresql/data | ||
ports: | ||
- '${POSTGRES_HOST_PORT}:${POSTGRES_CONTAINER_PORT}' | ||
networks: | ||
- my-app-network | ||
redis-server: | ||
image: redis:4.0-alpine | ||
env_file: .env | ||
volumes: | ||
- redis-data-volume:/data | ||
ports: | ||
- '${REDIS_HOST_PORT}:${REDIS_CONTAINER_PORT}' | ||
networks: | ||
- my-app-network | ||
volumes: | ||
pg-data-volume: | ||
redis-data-volume: | ||
networks: | ||
my-app-network: |
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
const knex = require('./knex'); | ||
const bookshelf = require('bookshelf')(knex); | ||
bookshelf.plugin('registry'); | ||
|
||
module.exports = bookshelf; |
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,2 @@ | ||
const config = require('../knexfile.js'); | ||
module.exports = require('knex')(config); |
File renamed without changes.
File renamed without changes.
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,13 @@ | ||
exports.seed = function(knex, Promise) { | ||
// Deletes ALL existing entries | ||
return knex('users').del() | ||
.then(function () { | ||
// Inserts seed entries | ||
return knex('users').insert([ | ||
{ username: 'ed' }, | ||
{ username: 'raymond' }, | ||
{ username: 'jason' } | ||
]); | ||
}); | ||
}; | ||
|
This file was deleted.
Oops, something went wrong.
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
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