Browse Source

add docker file

Ray Lee 5 years ago
parent
commit
a52234d18a
9 changed files with 97 additions and 55 deletions
  1. 15 0
      .dockerignore
  2. 6 0
      .editorconfig
  3. 11 0
      .gitignore
  4. 19 0
      Dockerfile
  5. 12 55
      README.md
  6. 34 0
      bitbucket-pipelines.yml
  7. 0 0
      server/lib/xfdftool/.keep
  8. 0 0
      static/pdfs/input/.keep
  9. 0 0
      static/pdfs/output/.keep

+ 15 - 0
.dockerignore

@@ -0,0 +1,15 @@
+.git
+.dockerignore
+.editorconfig
+bitbucket-pipelines.yml
+
+# ignore basic lib
+/server/lib/xfdftool/*
+!/server/lib/xfdftool/.keep
+/server/lib/MuPDF/*
+
+# ignore pdf files
+/static/pdfs/input/*
+!/static/pdfs/input/.keep
+/static/pdfs/output/*
+!/static/pdfs/output/.keep

+ 6 - 0
.editorconfig

@@ -0,0 +1,6 @@
+[*]
+indent_style = space
+end_of_line = lf
+indent_size = 2
+charset = utf-8
+trim_trailing_whitespace = true

+ 11 - 0
.gitignore

@@ -17,3 +17,14 @@
 npm-debug.log*
 yarn-debug.log*
 yarn-error.log*
+
+# ignore basic lib
+/server/lib/xfdftool/*
+!/server/lib/xfdftool/.keep
+/server/lib/MuPDF/*
+
+# ignore pdf files
+/static/pdfs/input/*
+!/static/pdfs/input/.keep
+/static/pdfs/output/*
+!/static/pdfs/output/.keep

+ 19 - 0
Dockerfile

@@ -0,0 +1,19 @@
+FROM node:10.14.0
+
+MAINTAINER Ray Lee <ray-lee@kdanmobile.com>
+
+ARG ENV=preparing
+ENV ENV $ENV
+EXPOSE 4000
+
+ENV INPUT_PATH
+ENV OUTPUT_PATH
+
+WORKDIR /app
+COPY ./server/lib/xfdftool /app/server/lib/xfdftool
+ADD . /app
+
+ARG BRANCH=none
+ARG COMMIT=none
+LABEL branch=$BRANCH commit=$COMMIT env=$ENV
+CMD NODE_ENV=production ENV=$ENV yarn start

+ 12 - 55
README.md

@@ -1,55 +1,12 @@
-# next-react-redux
-
-- [next-react-redux](#next-react-redux)
-  - [Packages](#packages)
-  - [How to start](#how-to-start)
-  - [Directory structure](#directory-structure)
-  - [Eslint config](#eslint-config)
-  - [Font face](#font-face)
-
-## Packages
-
-- eslint
-- next.js
-- React
-- Redux
-- immer
-- Redux saga
-- styled-components
-- next-i18next
-- isomorphic-unfetch
-- pre-commit
-- ...
-
-## How to start
-
-```
-yarn
-yarn dev
-```
-
-## Directory structure
-
-| name       | description                                |
-| ---------- | ------------------------------------------ |
-| pages      | nextjs route page and default setting file |
-| components | Presentational Components                  |
-| containers | Container Components                       |
-| actions    | redux action                               |
-| reducers   | redux reducer                              |
-| apis       | fetch data and send data api               |
-| constants  | and constant ex: style, action             |
-| hoc        | high order component                       |
-| sagas      | redux saga middleware                      |
-| static     | any static file                            |
-
-## Eslint config
-
-eslint-config-airbnb
-
-## Font face
-
-- English: Clear Sans
-- Japanese: Noto Sans Japanese
-- Simplified Chinese: Noto Sans SC
-- Traditional Chinese: Noto Sans TC
+# PDF Reader Web
+Web solution to view & highlight PDF Files
+
+# Preparing Environment
+    export PDF_INPUT_PATH=/path/to/input/folder
+    export PDF_OUTPUT_PATH=/path/to/output/folder
+
+# Service Start
+    docker run -d --restart on-failure --name pdf-reader-web \
+      -v $PDF_INPUT_PATH:/app/static/pdfs/input -v $PDF_OUTPUT_PATH:/app/static/pdfs/output \
+      -e PDF_INPUT_PATH -e PDF_OUTPUT_PATH -e ENV=production \
+      -p 4000:4000 pdf-reader-web

+ 34 - 0
bitbucket-pipelines.yml

@@ -0,0 +1,34 @@
+# This is a sample build configuration for Docker.
+# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples.
+# Only use spaces to indent your .yml configuration.
+# -----
+# You can specify a custom docker image from Docker Hub as your build environment.
+# image: atlassian/default-image:latest
+
+# enable Docker for your repository
+options:
+  docker: true
+
+image: node:10.14.0
+
+
+pipelines:
+  branches:
+    master:
+      - step:
+          script:
+            - yarn install
+            - yarn test
+            - NODE_ENV=production ENV=production yarn build
+            - docker build -t ${AWS_REGISTRY_URL}/pdf-reader-web:production --build-arg BRANCH=$BITBUCKET_BRANCH --build-arg COMMIT=$BITBUCKET_COMMIT --build-arg ENV=production .
+            - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
+            - docker push ${AWS_REGISTRY_URL}/pdf-reader-web:production
+    develop:
+      - step:
+          script:
+            - yarn install
+            - yarn test
+            - NODE_ENV=production ENV=preparing yarn build
+            - docker build -t ${AWS_REGISTRY_URL}/pdf-reader-web:preparing --build-arg BRANCH=$BITBUCKET_BRANCH --build-arg COMMIT=$BITBUCKET_COMMIT --build-arg ENV=preparing .
+            - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
+            - docker push ${AWS_REGISTRY_URL}/pdf-reader-web:preparing

+ 0 - 0
server/lib/xfdftool/.keep


+ 0 - 0
static/pdfs/input/.keep


+ 0 - 0
static/pdfs/output/.keep