Trying to get node docker setup but oddly it works locally and not in prod.

This commit is contained in:
Samuel Clay 2021-02-24 17:17:06 -05:00
parent 6c45c465ae
commit cf3bec14ad
6 changed files with 42 additions and 47 deletions

View file

@ -1,6 +1,8 @@
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
.PHONY: node
#creates newsblur, but does not rebuild images or create keys
start:
- CURRENT_UID=${CURRENT_UID} CURRENT_GID=${CURRENT_GID} docker-compose up -d
@ -66,16 +68,29 @@ apply:
terraform -chdir=terraform apply
# Docker
images:
build_web:
- 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_node
node_image: build_node
- docker push newsblur/newsblur_node
# Tasks
deploy:
- 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:
- ansible-playbook ansible/provision.yml --tags firewall -l db

View file

@ -13,7 +13,6 @@
- name: Installing Zsh and git
apt: pkg=zsh,git state=latest
register: installation
- name: Set zsh as default shell
user: name=nb shell=/usr/bin/zsh
@ -21,10 +20,9 @@
- name: Cloning oh-my-zsh
git:
repo=https://github.com/robbyrussell/oh-my-zsh
dest=~/.oh-my-zsh
when: installation is success
register: cloning
repo: https://github.com/robbyrussell/oh-my-zsh
dest: /home/nb/.oh-my-zsh
force: yes
- name: Copy toprc
copy: src=toprc.txt dest=~/.toprc

View file

@ -6,32 +6,33 @@
image: newsblur/newsblur_node
state: started
command: "{{ item.command }}"
container_default_behavior: no_defaults
pull: true
ports:
- "{{ item.ports }}"
env:
NODE_ENV: "docker"
NODE_ENV: "production"
restart_policy: unless-stopped
volumes:
- /srv/newsblur/node:/usr/src/app
- /srv/newsblur/node:/srv/newsblur/node
with_items:
- container_name: node_websocket
- container_name: node_socket
ports: 8888:8888
command: node unread_counts.js
target_host: 'node-socket'
- container_name: 'original_pages'
ports: '3060:3060'
command: 'node original_page.js'
target_host: 'node_page'
target_host: 'node-page'
- container_name: 'original_text'
ports: '4040:4040'
command: 'node original_text.js'
target_host: 'node_text'
target_host: 'node-text'
- container_name: 'favicons'
ports: '3030:3030'
command: 'node favicons.js'
target_host: 'node-favicons'
when: "'{{item.target_host}}' in ansible_hostname"
when: item.target_host in inventory_hostname
- name: Register nodes in consul
@ -54,4 +55,4 @@
target_host: 'node-images'
notify:
- reload consul
when: "'{{item.target_host}}' in ansible_hostname"
when: item.target_host in inventory_hostname

12
docker/node/Dockerfile Normal file
View 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 ./

View file

@ -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
View file

@ -0,0 +1,2 @@
node_modules
npm-debug.log