Skip to content

Commit

Permalink
feat: first pass at putting this project into the reaction docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nnnnat committed Apr 4, 2018
1 parent 70254f3 commit 749b980
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NODE_ENV=development
PROTOCOL=HTTP
HOST=localhost
PORT=3030
ENDPOINT=graphql-alpha
METEOR_TOKEN=ABC
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.vscode
.idea
.c9
.env
*.csv
*.dat
*.gz
Expand Down
15 changes: 15 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Yarn Config - configured for running inside Docker Compose

# Configure Yarn offline mirror for improved performance.
# https://yarnpkg.com/blog/2016/11/24/offline-mirror/
#
# If you need to ensure clean cached modules follow the guide:
# https://yarnpkg.com/blog/2016/11/24/offline-mirror/#updating-your-package
#
yarn-offline-mirror "/home/node/.cache/yarn-offline-mirror"
yarn-offline-mirror-pruning true

--install.cache-folder /home/node/.cache/yarn
--install.ignore-scripts true
--install.modules-folder /usr/local/src/node_modules
--install.prefer-offline true
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
FROM node:8-alpine

ARG NAME=reaction-next-starterkit
ARG DESCRIPTION=""
ARG URL=https://github.com/reactioncommerce/reaction-next-starterkit
ARG DOC_URL=https://github.com/reactioncommerce/reaction-next-starterkit
ARG VCS_URL=https://github.com/reactioncommerce/reaction-next-starterkit
ARG VCS_REF
ARG VENDOR
ARG BUILD_DATE
ARG BUILD_COMPARE_URL
ARG BUILD_ENV=test
ARG BUILD_NUMBER
ARG BUILD_PLATFORM
ARG BUILD_PLATFORM_PROJECT_USERNAME
ARG BUILD_PLATFORM_PROJECT_REPONAME
ARG BUILD_PULL_REQUESTS
ARG BUILD_TRIGGERED_BY_TAG
ARG BUILD_URL
ARG CIRCLE_WORKSPACE_ID
ARG CIRCLE_WORKFLOW_ID
ARG CIRCLE_WORKFLOW_JOB_ID
ARG CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS
ARG CIRCLE_WORKSPACE_ID
ARG GIT_REPOSITORY_URL
ARG GIT_SHA1
ARG LICENSE

ENV APP_SOURCE_DIR=/usr/local/src/reaction-app \
PATH=$PATH:/usr/local/src/node_modules/.bin

LABEL maintainer="Reaction Commerce <[email protected]>" \
com.reactioncommerce.build-date=$BUILD_DATE \
com.reactioncommerce.name=$NAME \
com.reactioncommerce.description=$DESCRIPTION \
com.reactioncommerce.url=$URL \
com.reactioncommerce.vcs-url=$VCS_URL \
com.reactioncommerce.vcs-ref=$VCS_REF \
com.reactioncommerce.vendor=$VENDOR \
com.reactioncommerce.docker.build.compare-url=$BUILD_COMPARE_URL \
com.reactioncommerce.docker.build.number=$BUILD_NUMBER \
com.reactioncommerce.docker.build.platform=$BUILD_PLATFORM \
com.reactioncommerce.docker.build.platform.project.username=$BUILD_PLATFORM_PROJECT_USERNAME \
com.reactioncommerce.docker.build.platform.project.reponame=$BUILD_PLATFORM_PROJECT_REPONAME \
com.reactioncommerce.docker.build.pull-requests=$BUILD_PULL_REQUESTS \
com.reactioncommerce.docker.build.triggered-by-tag=$BUILD_TRIGGERED_BY_TAG \
com.reactioncommerce.docker.build.url=$BUILD_URL \
com.reactioncommerce.docker.build.circle.workflow.id=$CIRCLE_WORKFLOW_ID \
com.reactioncommerce.docker.build.circle.workflow.job.id=$CIRCLE_WORKFLOW_JOB_ID \
com.reactioncommerce.docker.build.circle.workflow.upstream.job.ids=$CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS \
com.reactioncommerce.docker.build.circle.workflow.url=https://circleci.com/workflow-run/$CIRCLE_WORKFLOW_ID \
com.reactioncommerce.docker.build.circle.workspace.id=$CIRCLE_WORKSPACE_ID \
com.reactioncommerce.docker.git.repository.url=$GIT_REPOSITORY_URL \
com.reactioncommerce.docker.git.sha1=$GIT_SHA1 \
com.reactioncommerce.docker.license=$LICENSE

WORKDIR $APP_SOURCE_DIR/..
COPY package.json yarn.lock $APP_SOURCE_DIR/../

# Build the dependencies into the Docker image in a cacheable way. Dependencies
# are only rebuilt when package.json or yarn.lock is modified.
#
# The project directory will be mounted during development. Therefore, we'll
# install dependencies into an external directory (one level up.) This works
# because Node traverses up the fs to find node_modules.
RUN set -ex; \
if [ "$BUILD_ENV" = "production" ]; then \
yarn install \
--frozen-lockfile \
--ignore-scripts \
--no-cache \
--production; \
elif [ "$BUILD_ENV" = "test" ]; then \
yarn install \
--frozen-lockfile \
--ignore-scripts \
--no-cache; \
elif [ "$BUILD_ENV" = "development" ]; then \
yarn install \
--cache-folder /home/node/.cache/yarn \
--ignore-scripts; \
fi; \
rm package.json yarn.lock

WORKDIR $APP_SOURCE_DIR
COPY . $APP_SOURCE_DIR

# RUN yarn run build

CMD ["yarn start"]
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.4'

services:
web:
build:
context: .
args:
BUILD_ENV: "development"
command: [sh, -c, "yarn dev"]
env_file:
- ./.env
environment:
REACTION_APP_NAME: "reaction-next-starterkit.web"
ports:
- 4000:3000
volumes:
- $HOME/.cache/yarn-offline-mirror:/home/node/.cache/yarn-offline-mirror
- web-yarn:/home/node/.cache/yarn
- .:/usr/local/src/reaction-app

volumes:
web-yarn:
Empty file added yarn.lock
Empty file.

0 comments on commit 749b980

Please sign in to comment.