mirror of
https://github.com/viq/NewsBlur.git
synced 2025-04-13 09:38:09 +00:00
Trying to get node docker setup but oddly it works locally and not in prod.
This commit is contained in:
parent
6c45c465ae
commit
cf3bec14ad
6 changed files with 42 additions and 47 deletions
19
Makefile
19
Makefile
|
@ -1,6 +1,8 @@
|
||||||
CURRENT_UID := $(shell id -u)
|
CURRENT_UID := $(shell id -u)
|
||||||
CURRENT_GID := $(shell id -g)
|
CURRENT_GID := $(shell id -g)
|
||||||
|
|
||||||
|
.PHONY: node
|
||||||
|
|
||||||
#creates newsblur, but does not rebuild images or create keys
|
#creates newsblur, but does not rebuild images or create keys
|
||||||
start:
|
start:
|
||||||
- CURRENT_UID=${CURRENT_UID} CURRENT_GID=${CURRENT_GID} docker-compose up -d
|
- CURRENT_UID=${CURRENT_UID} CURRENT_GID=${CURRENT_GID} docker-compose up -d
|
||||||
|
@ -66,16 +68,29 @@ apply:
|
||||||
terraform -chdir=terraform apply
|
terraform -chdir=terraform apply
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
images:
|
build_web:
|
||||||
- docker image build . --file=docker/newsblur_base_image.Dockerfile --tag=newsblur/newsblur_python3
|
- docker image build . --file=docker/newsblur_base_image.Dockerfile --tag=newsblur/newsblur_python3
|
||||||
- docker image build . --file=docker/node/node_base.Dockerfile --tag=newsblur/newsblur_node
|
build_node:
|
||||||
|
- docker image build . --file=docker/node/Dockerfile --tag=newsblur/newsblur_node
|
||||||
|
build: build_web build_node
|
||||||
|
|
||||||
|
images: build
|
||||||
- docker push newsblur/newsblur_python3
|
- docker push newsblur/newsblur_python3
|
||||||
- docker push newsblur/newsblur_node
|
- docker push newsblur/newsblur_node
|
||||||
|
|
||||||
|
node_image: build_node
|
||||||
|
- docker push newsblur/newsblur_node
|
||||||
|
|
||||||
# Tasks
|
# Tasks
|
||||||
deploy:
|
deploy:
|
||||||
- ansible-playbook ansible/deploy_app.yml
|
- ansible-playbook ansible/deploy_app.yml
|
||||||
|
|
||||||
|
app:
|
||||||
|
- ansible-playbook ansible/provision.yml -l app --tags web
|
||||||
|
|
||||||
|
node:
|
||||||
|
- ansible-playbook ansible/provision.yml -l node --tags node
|
||||||
|
|
||||||
firewall:
|
firewall:
|
||||||
- ansible-playbook ansible/provision.yml --tags firewall -l db
|
- ansible-playbook ansible/provision.yml --tags firewall -l db
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
- name: Installing Zsh and git
|
- name: Installing Zsh and git
|
||||||
apt: pkg=zsh,git state=latest
|
apt: pkg=zsh,git state=latest
|
||||||
register: installation
|
|
||||||
|
|
||||||
- name: Set zsh as default shell
|
- name: Set zsh as default shell
|
||||||
user: name=nb shell=/usr/bin/zsh
|
user: name=nb shell=/usr/bin/zsh
|
||||||
|
@ -21,10 +20,9 @@
|
||||||
|
|
||||||
- name: Cloning oh-my-zsh
|
- name: Cloning oh-my-zsh
|
||||||
git:
|
git:
|
||||||
repo=https://github.com/robbyrussell/oh-my-zsh
|
repo: https://github.com/robbyrussell/oh-my-zsh
|
||||||
dest=~/.oh-my-zsh
|
dest: /home/nb/.oh-my-zsh
|
||||||
when: installation is success
|
force: yes
|
||||||
register: cloning
|
|
||||||
|
|
||||||
- name: Copy toprc
|
- name: Copy toprc
|
||||||
copy: src=toprc.txt dest=~/.toprc
|
copy: src=toprc.txt dest=~/.toprc
|
||||||
|
|
|
@ -6,32 +6,33 @@
|
||||||
image: newsblur/newsblur_node
|
image: newsblur/newsblur_node
|
||||||
state: started
|
state: started
|
||||||
command: "{{ item.command }}"
|
command: "{{ item.command }}"
|
||||||
|
container_default_behavior: no_defaults
|
||||||
pull: true
|
pull: true
|
||||||
ports:
|
ports:
|
||||||
- "{{ item.ports }}"
|
- "{{ item.ports }}"
|
||||||
env:
|
env:
|
||||||
NODE_ENV: "docker"
|
NODE_ENV: "production"
|
||||||
restart_policy: unless-stopped
|
restart_policy: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- /srv/newsblur/node:/usr/src/app
|
- /srv/newsblur/node:/srv/newsblur/node
|
||||||
with_items:
|
with_items:
|
||||||
- container_name: node_websocket
|
- container_name: node_socket
|
||||||
ports: 8888:8888
|
ports: 8888:8888
|
||||||
command: node unread_counts.js
|
command: node unread_counts.js
|
||||||
target_host: 'node-socket'
|
target_host: 'node-socket'
|
||||||
- container_name: 'original_pages'
|
- container_name: 'original_pages'
|
||||||
ports: '3060:3060'
|
ports: '3060:3060'
|
||||||
command: 'node original_page.js'
|
command: 'node original_page.js'
|
||||||
target_host: 'node_page'
|
target_host: 'node-page'
|
||||||
- container_name: 'original_text'
|
- container_name: 'original_text'
|
||||||
ports: '4040:4040'
|
ports: '4040:4040'
|
||||||
command: 'node original_text.js'
|
command: 'node original_text.js'
|
||||||
target_host: 'node_text'
|
target_host: 'node-text'
|
||||||
- container_name: 'favicons'
|
- container_name: 'favicons'
|
||||||
ports: '3030:3030'
|
ports: '3030:3030'
|
||||||
command: 'node favicons.js'
|
command: 'node favicons.js'
|
||||||
target_host: 'node-favicons'
|
target_host: 'node-favicons'
|
||||||
when: "'{{item.target_host}}' in ansible_hostname"
|
when: item.target_host in inventory_hostname
|
||||||
|
|
||||||
|
|
||||||
- name: Register nodes in consul
|
- name: Register nodes in consul
|
||||||
|
@ -54,4 +55,4 @@
|
||||||
target_host: 'node-images'
|
target_host: 'node-images'
|
||||||
notify:
|
notify:
|
||||||
- reload consul
|
- reload consul
|
||||||
when: "'{{item.target_host}}' in ansible_hostname"
|
when: item.target_host in inventory_hostname
|
||||||
|
|
12
docker/node/Dockerfile
Normal file
12
docker/node/Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM node:14.4.0
|
||||||
|
WORKDIR /srv/newsblur/node
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Install app dependencies
|
||||||
|
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
||||||
|
# where available (npm@5+)
|
||||||
|
COPY node/package*.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY node/*.js ./
|
|
@ -1,33 +0,0 @@
|
||||||
FROM node:14.4.0
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
RUN set -ex \
|
|
||||||
&& rundDeps=' \
|
|
||||||
libpq5 \
|
|
||||||
libjpeg62 \
|
|
||||||
libxslt1.1 \
|
|
||||||
' \
|
|
||||||
&& buildDeps=' \
|
|
||||||
patch \
|
|
||||||
python-dev \
|
|
||||||
gfortran \
|
|
||||||
lib32ncurses5-dev \
|
|
||||||
libblas-dev \
|
|
||||||
libffi-dev \
|
|
||||||
libjpeg-dev \
|
|
||||||
default-libmysqlclient-dev \
|
|
||||||
libpq-dev \
|
|
||||||
libreadline6-dev \
|
|
||||||
liblapack-dev \
|
|
||||||
libxml2-dev \
|
|
||||||
libxslt1-dev \
|
|
||||||
ncurses-dev \
|
|
||||||
zlib1g-dev \
|
|
||||||
' \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y $rundDeps $buildDeps --no-install-recommends \
|
|
||||||
&& apt-get purge -y --auto-remove ${buildDeps} \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY ./node/package.json /usr/src/app/package.json
|
|
||||||
COPY ./node/package-lock.json /usr/src/app/package-lock.json
|
|
||||||
RUN npm install
|
|
2
node/.dockerignore
Normal file
2
node/.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
Loading…
Add table
Reference in a new issue