Skip to content
Permalink
Browse files

Fix docker images

- Since dotenv is used, remove the gitignore and version the whole config.js file
- Fixes #60 -- add python and build-base to the alpine image
- Lower the UID by one to not conflict with nogroup in the alpine image
- Nuke the slim image as it adds very little benefit.
- Update docs accordingly
- Update yarn lock file
- Update docs to have users install yarn
  • Loading branch information...
robbyoconnor committed Jul 29, 2018
1 parent f2686e0 commit 4ca7c01aa1378c7ab6a21654b3e7a9c77f60e8df
@@ -2,7 +2,7 @@
teleirc.service
README.md
LICENSE
Dockerfile*
docker-compose*
containers/Dockerfile*
containers/docker-compose*
node_modules*
tests/*
@@ -27,23 +27,25 @@ build/Release
# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules
config.js
.env
docker-compose.yml

# ---> Python (for docs)
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
.Python
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
.venv
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
.Python
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
.venv
pip-selfcheck.json

# Sphinx docs output
docs/_build

# Docker Compose file
# Remove when image is pushed to Docker Hub or similar
docker-compose.yml
@@ -8,7 +8,6 @@ node_js:

before_install:
- cp .env.example .env
- cp config.js.example config.js

install:
- yarn
File renamed without changes.
@@ -1,8 +1,8 @@
FROM node:8-alpine

RUN apk add --no-cache --update bash \
&& addgroup -g 65533 teleirc \
&& adduser -s /bin/bash -h /opt/teleirc -D -H teleirc -u 65533 -G teleirc
RUN apk add --no-cache --update bash build-base python \
&& addgroup -g 65532 teleirc \
&& adduser -s /bin/bash -h /opt/teleirc -D -H teleirc -u 65532 -G teleirc

WORKDIR /opt/teleirc
CMD ["node", "teleirc.js"]
@@ -12,4 +12,4 @@ COPY config.js.example /opt/teleirc/config.js
RUN chown -R teleirc:teleirc /opt/teleirc

USER teleirc
RUN npm install
RUN yarn
@@ -1,18 +1,19 @@
FROM fedora
# Cache layers which will not change
RUN groupadd teleirc -g 65533 \
&& useradd -u 65533 -g teleirc -s /bin/bash -M -d /opt/teleirc teleirc
RUN groupadd teleirc -g 65532 \
&& useradd -u 65532 -g teleirc -s /bin/bash -M -d /opt/teleirc teleirc

WORKDIR /opt/teleirc
CMD ["node", "teleirc.js"]

COPY . /opt/teleirc/
COPY config.js.example /opt/teleirc/config.js

RUN dnf -y update --setopt=deltarpm=false \
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo \
&& dnf -y update --setopt=deltarpm=false \
&& dnf clean all \
&& dnf -y install nodejs libicu-devel python gcc-c++ make --setopt=deltarpm=false \
&& npm install \
&& dnf -y install nodejs libicu-devel python gcc-c++ make yarn --setopt=deltarpm=false \
&& yarn \
&& dnf -y remove libicu-devel gcc-c++ make \
&& dnf clean all \
&& chown -R teleirc:teleirc /opt/teleirc

This file was deleted.

@@ -5,7 +5,7 @@ version: '2'
services:
teleirc:
build:
context: .
dockerfile: Dockerfile.alpine
env_file: .env
context: ..
dockerfile: containers/Dockerfile.alpine
env_file: ../.env
user: teleirc
@@ -46,7 +46,7 @@ Requirements
============

- git
- nodejs (8.x.x)
- nodejs (8.x.x) -- we strongly recommend `nvm <https://github.com/creationix/nvm/blob/master/README.md>`_ as the installation method.

Download
========
@@ -57,21 +57,41 @@ Download

#. Change directories to repo

#. Install dependencies with ``npm``
#. Install `yarn <https://yarnpkg.com/en/docs/install>`_ via one of the following methods (we will only Linux, `yarn install documentation <https://yarnpkg.com/en/docs/install>`_ cover the rest)

- ``npm install``
- Arch Linux

#. Copy the base configuration to a local configuration
.. code-block:: shell
- ``cp config.js.example config.js``
pacman -S yarn
- Debian/Ubuntu

.. code-block:: shell
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update ; sudo apt-get install --no-install-recommends yarn
- Fedora/CentOS/RHEL:

.. code-block:: shell
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn or dnf install yarn
#. Install dependencies using yarn

- ``yarn``

Configuration
=============

Teleirc uses `dotenv <https://www.npmjs.com/package/dotenv>`_ for easy management of API keys and settings.
All your configuration changes will live in the ``.env`` file.
You should not need to change other files.
This makes it possible to use ``git pull`` to upgrade the bot in place.
This makes it possible to use ``git pull`` to upgrade the bot in-place.

Explaining config file
----------------------
@@ -10,22 +10,20 @@ Install Docker onto the machine you plan to run Teleirc from.
Which image do I choose?
************************

Node Slim, Official Node Alpine Linux, and Fedora images are provided (ordered ascending by size).
Official Node Alpine Linux, and Fedora images are provided (ordered ascending by size).

+-----------------------------------------------------------------------------+-----------------------+---------+
| Image | File | Size |
+=============================================================================+=======================+=========+
| `Node Alpine Linux <https://hub.docker.com/r/_/node/>`_ (``node:6-alpine``) | ``Dockerfile.alpine`` | 66.9 MB |
+-----------------------------------------------------------------------------+-----------------------+---------+
| `Node Slim <https://hub.docker.com/r/_/node/>`_ (``node:6-slim``) | ``Dockerfile.slim`` | 256 MB |
| `Node Alpine Linux <https://hub.docker.com/r/_/node/>`_ (``node:8-alpine``) | ``Dockerfile.alpine`` | 374 MB |
+-----------------------------------------------------------------------------+-----------------------+---------+
| `Fedora latest <https://hub.docker.com/r/_/fedora/>`_ | ``Dockerfile.fedora`` | 569 MB |
+-----------------------------------------------------------------------------+-----------------------+---------+

This guide uses ``alpine``.
If you use another image, replace ``alpine`` with ``slim`` or ``fedora``.
If you wish to use ``fedora``, replace ``alpine`` with ``fedora``.

You will see errors during ``npm install``.
You will see errors during ``yarn``.
You can safely ignore them.
They are not fatal.

@@ -52,7 +50,7 @@ Docker Compose
**************

Optionally, you may use `docker-compose <https://docs.docker.com/compose>`_.
We provide an example compose file (``containers/docker-compose.yml.example``).
We provide an example compose file (``containers/docker-compose.yml``).

.. code-block:: yaml
@@ -61,16 +59,16 @@ We provide an example compose file (``containers/docker-compose.yml.example``).
teleirc:
user: teleirc
build:
context: .
dockerfile: Dockerfile.alpine
context: ..
dockerfile: containers/Dockerfile.alpine
env_file: .env
We ignore the ``docker-compose.yml`` file in ``.gitignore``.

Running with Compose
====================

Run these commands to begin using Teleirc with Docker Compose.

#. Copy ``containers/docker-compose.yml.example`` to ``docker-compose.yml``

#. Copy ``docker-compose.yml.example`` to ``docker-compose.yml`` and edit if you do not wish to use the alpine image
#. Copy ``.env.example`` to ``.env`` and edit accordingly.
#. ``docker-compose up -d teleirc``
@@ -495,6 +495,10 @@ nan@^2.3.5:
version "2.5.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2"

node-bin-setup@^1.0.0:
version "1.0.6"
resolved "https://registry.yarnpkg.com/node-bin-setup/-/node-bin-setup-1.0.6.tgz#4b5c9bb937ece702d7069b36ca78af4684677528"

node-icu-charset-detector@~0.1.2:
version "0.1.4"
resolved "https://registry.yarnpkg.com/node-icu-charset-detector/-/node-icu-charset-detector-0.1.4.tgz#4979c21f72cf4f79cbeec27b586d6f7138d0c9cd"
@@ -519,6 +523,12 @@ node-uuid@~1.4.7:
version "1.4.7"
resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f"

node@~8:
version "8.11.3"
resolved "https://registry.yarnpkg.com/node/-/node-8.11.3.tgz#b9efe2c3f4c8c84ee78439b119d768ad3b30eed6"
dependencies:
node-bin-setup "^1.0.0"

oauth-sign@~0.8.1, oauth-sign@~0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"

0 comments on commit 4ca7c01

Please sign in to comment.
You can’t perform that action at this time.