Procházet zdrojové kódy

move to alpine for docker (#195)

* swich to node alpine and create seperate file for production

* add to dockerignore

* Update Dockerfile

* build theme

* use yarn in build scritps

*  add build dep for alpine

* dont ignore env.example
pull/200/head
Cian Butler před 4 roky
committed by GitHub
rodič
revize
29e2500c05
9 změnil soubory, kde provedl 51 přidání a 16 odebrání
  1. +17
    -0
      .dockerignore
  2. +1
    -1
      .env.example
  3. +7
    -4
      Dockerfile
  4. +1
    -0
      _config.yml
  5. +6
    -5
      docker-compose.yml
  6. +1
    -0
      lib/smtpTransport.js
  7. +5
    -6
      package.json
  8. +13
    -0
      production/docker-compose.yml
  9. +0
    -0
      production/website.service

+ 17
- 0
.dockerignore Zobrazit soubor

@@ -1,6 +1,23 @@
node_modules
db.json
.npm
scaffolds
.deploy_git
public
.DS_stores
docker-compose.yml
Dockerfile
production
*.md
.circleci
circle.yml
.env
.eslint*
.nvm*
.codeclimate.yml
.dockerignore
.markdown.style.rb
.mdlrc
logs
npm-shrinkwrap.json
themes

+ 1
- 1
.env.example Zobrazit soubor

@@ -1,5 +1,5 @@
SECRET_API_TOKEN=somethingThatMustChange
RECAPTCHA_SITE_KEY=6LfClyATAAAAAD19Z-ReiK4xsGVCMWuTF4f9FMr_
RECAPTCHA_SITE_KEY=6LdCuwgUAAAAAKB3yf7AcOpyHxIFKJNaH3cNhmEC
RECAPTCHA_SECRET_KEY=
LOG_ROTATE=24h
SMTP_HOST=mailhost.redbrick.dcu.ie


+ 7
- 4
Dockerfile Zobrazit soubor

@@ -1,5 +1,8 @@
FROM node:boron-onbuild
ENV NODE_ENV=production
VOLUME /usr/src/app/public
VOLUME /usr/src/app/logs
FROM node:boron-alpine
WORKDIR /usr/src/app
VOLUME /usr/src/app/public /usr/src/app/logs
EXPOSE 3000
ADD . /usr/src/app/
RUN apk add --no-cache git build-base file nasm autoconf libpng-dev openssl && yarn
ENV NODE_ENV=production
CMD yarn docker

+ 1
- 0
_config.yml Zobrazit soubor

@@ -229,6 +229,7 @@ server:
host: smtp.redbrick.dcu.ie
port: '465'
secure: 'true'
authMethod: 'plain'
auth:
user: ''
pass: ''


+ 6
- 5
docker-compose.yml Zobrazit soubor

@@ -1,12 +1,13 @@
version: "3"
services:
redbrick:
image: 'redbrick/site:latest'
container_name: 'redbrick-site'
restart: 'always'
command: ["npm", "run", "start"]
build: .
command: 'yarn start'
volumes:
- $PWD:/usr/src/app
- $PWD/logs:/usr/src/app/logs
- $PWD/public:/usr/src/app/public
ports:
- '3000:3000'
env_file: .env
environment:
NODE_ENV: development

+ 1
- 0
lib/smtpTransport.js Zobrazit soubor

@@ -10,6 +10,7 @@ const smtp = config.email;
smtp.host = process.env.SMTP_HOST || config.email.host;
smtp.port = process.env.SMTP_PORT || config.email.port;
smtp.secure = process.env.SMTP_SECURE || config.email.secure;
smtp.authMethod = process.env.SMTP_AUTH_METHOD || config.email.authMethod;
smtp.user = process.env.SMTP_USER || config.email.user;
smtp.pass = process.env.SMTP_PASS || config.email.pass;



+ 5
- 6
package.json Zobrazit soubor

@@ -13,18 +13,17 @@
"license": "MIT",
"scripts": {
"server": "node ./bin/www",
"test": "npm run lint && npm run generate",
"test": "yarn lint && yarn generate",
"theme": "git submodule init && git submodule update --remote",
"postinstall": "npm run theme && cd themes/redbrick-theme && npm install",
"postinstall": "yarn theme && cd themes/redbrick-theme && yarn",
"generate": "hexo g",
"hexo": "hexo s",
"dev": "npm run hexo",
"page": "hexo new page",
"post": "hexo new post",
"docker": "git pull origin master && npm start",
"start": "npm run generate && node ./bin/www ",
"docker": "git pull origin master && yarn start",
"start": "yarn generate && node ./bin/www ",
"fresh": "hexo clean",
"regenerate": "npm run postinstall && hexo clean && hexo g",
"regenerate": "yarn postinstall && hexo clean && hexo g",
"fix": "eslint . --fix",
"lint": "eslint ."
},


+ 13
- 0
production/docker-compose.yml Zobrazit soubor

@@ -0,0 +1,13 @@
version: "3"
services:
redbrick:
image: 'redbrick/site:latest'
container_name: 'redbrick-site'
command: 'yarn docker'
restart: 'always'
volumes:
- $PWD/logs:/usr/src/app/logs
- $PWD/public:/usr/src/app/public
ports:
- '3000:3000'
env_file: .env

website.service → production/website.service Zobrazit soubor


Načítá se…
Zrušit
Uložit