Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update local development to use prebuilt anzusystems node docker image #12

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PUBSUB_TOPIC=notification_server_internal

APP_INSTANCE_NAME=notification-local

WEBSOCKET_SERVER_PORT=3005
WEBSOCKET_SERVER_PORT=3010
WEBSOCKET_SERVER_CORS=^http://[a-zA-Z0-9-_.]+.anzusystems.localhost(:\d{2,4})?$

SSO_JWT_COOKIES=anz_jp,anz_js
Expand Down
4 changes: 3 additions & 1 deletion .env.docker.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
### Docker configuration

# Docker Nginx setup
NGINX_PROXYPASS_CONFIG=true
NGINX_PORT=8490
NGINX_UPSTREAM_WEBSOCKET_PORT=3410
NGINX_UPSTREAM_WEBSOCKET_PORT=3010

# Docker Node setup
DOCKER_NODE_AUTOSTART=true
Expand Down
42 changes: 25 additions & 17 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
name: CI for AnzuSystems Notification-Server by Petit Press a.s. (www.sme.sk)

on:
push:
branches:
- '**'
pull_request:
branches:
- main

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build:
lint:
strategy:
matrix:
node-version:
- '20'
platform:
- ubuntu-latest

name: Node ${{ matrix.node-version }} on ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
include:
- node-version: 20
docker-image: anzusystems/node:1.0.0-node20

name: Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
container:
image: ${{ matrix.docker-image }}
options: --user root
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
- name: Cache Yarn packages
id: yarn-cache
uses: actions/cache@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Enable corepack
run: corepack enable
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', '*/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn install --immutable
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ services:
dockerfile: docker/app/local/Dockerfile
environment:
- VIRTUAL_HOST=notification-server.anzusystems.local
- VIRTUAL_PORT=8080
- VIRTUAL_PORT=${NGINX_PORT:-8490}
env_file:
- .env.docker.dist
- .env.docker.local
volumes:
- ".:/var/www/html:cached"
ports:
- ${NGINX_PORT:-8490}:8080
- ${NGINX_UPSTREAM_WEBSOCKET_PORT:-3410}:3005
- ${NGINX_PORT:-8490}:${NGINX_PORT:-8490}
- ${NGINX_UPSTREAM_WEBSOCKET_PORT:-3010}:${NGINX_UPSTREAM_WEBSOCKET_PORT:-3010}
hostname: notification-server.anzusystems.local
networks:
anzusystems_network:
Expand Down
142 changes: 12 additions & 130 deletions docker/app/local/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,137 +1,19 @@
FROM node:20-bookworm-slim
FROM anzusystems/node:1.0.0-node20-nginx

# ----------------------------------------------------------------------------------------------------------------------
# ENVIRONMENT VARIABLES
# ----------------------------------------------------------------------------------------------------------------------
#
### Basic arguments and variables
ARG DOCKER_USER
ARG DOCKER_USER_ID
ARG DOCKER_GROUP_ID
# Versions
# Nginx version
ENV NGINX_VERSION=1.24.0 \
NGINX_NJS_VERSION=0.8.1 \
NGINX_PKG_RELEASE=1~bookworm \
# Supervisor version
SUPERVISOR_VERSION=4.2.5 \
SUPERVISOR_PKG_RELEASE=1 \
# NPM version
NPM_VERSION=10.2.1 \
# Yarn version
DOCKER_YARN_VERSION=4.0.1
# Common environment variables
ENV CONTAINER_STOP_LOG_FILE="/var/www/html/var/log/container_stop.log" \
COREPACK_HOME="/usr/lib/node/corepack" \
MAIN_TERMINATED_FILE="/var/www/html/var/log/main-terminated" \
NPM_CONFIG_LOGLEVEL=notice \
YARN_CACHE_FOLDER="/var/cache/yarn" \
YARN_ENABLE_TELEMETRY=0 \
# Unset yarn version - it could break things
YARN_VERSION=
# Packages
ENV RUN_DEPS="ca-certificates \
curl \
g++ \
gcc \
gettext-base \
git \
gnupg \
less \
logrotate \
lsb-release \
make \
openssh-client \
procps \
vim \
wget"

# ----------------------------------------------------------------------------------------------------------------------
# PACKAGES
# ----------------------------------------------------------------------------------------------------------------------
RUN apt-get update && \
apt-get install -y \
${RUN_DEPS} \
supervisor=${SUPERVISOR_VERSION}-${SUPERVISOR_PKG_RELEASE} && \
# Cleanup
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# ----------------------------------------------------------------------------------------------------------------------
# NPM + YARN
# Install static npm and yarn version
# ----------------------------------------------------------------------------------------------------------------------
RUN npm install --location=global npm@${NPM_VERSION} && \
mkdir -p ${COREPACK_HOME} && \
corepack prepare yarn@${DOCKER_YARN_VERSION} --activate && \
corepack enable

# ----------------------------------------------------------------------------------------------------------------------
# NGINX
# ----------------------------------------------------------------------------------------------------------------------
RUN NGINX_KEYRING=/usr/share/keyrings/nginx-archive-keyring.gpg && \
NGINX_REPO=nginx && \
echo "deb [signed-by=${NGINX_KEYRING}] http://nginx.org/packages/debian $(lsb_release -cs) ${NGINX_REPO}" > /etc/apt/sources.list.d/${NGINX_REPO}.list && \
curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor > ${NGINX_KEYRING} && \
apt-get update && \
apt-get install --no-install-recommends --no-install-suggests -y \
nginx=${NGINX_VERSION}-${NGINX_PKG_RELEASE} \
nginx-module-xslt=${NGINX_VERSION}-${NGINX_PKG_RELEASE} \
nginx-module-geoip=${NGINX_VERSION}-${NGINX_PKG_RELEASE} \
nginx-module-image-filter=${NGINX_VERSION}-${NGINX_PKG_RELEASE} \
nginx-module-njs=${NGINX_VERSION}+${NGINX_NJS_VERSION}-${NGINX_PKG_RELEASE} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# ----------------------------------------------------------------------------------------------------------------------
# USER SETUP
# ----------------------------------------------------------------------------------------------------------------------
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log && \
mkdir -p /run/nginx && \
chown node:node -R \
/etc/nginx \
/run/nginx \
/var/log/nginx && \
sed -i 's/^#alias l/alias l/g' /home/node/.bashrc && \
echo "update-notifier=false" > /home/node/.npmrc && \
mkdir -p \
${YARN_CACHE_FOLDER} \
/var/cache/nginx \
/usr/local/lib/node_modules \
/var/run/supervisor \
/var/www/html/var && \
chown node:node -R \
${COREPACK_HOME} \
${YARN_CACHE_FOLDER} \
/etc/nginx \
/home/node/.npmrc \
/run/nginx \
/usr/local/bin \
/usr/local/lib/node_modules \
/var/cache/nginx \
/var/log/nginx \
/var/run/supervisor \
/var/www/html

# ----------------------------------------------------------------------------------------------------------------------
# RUN CONFIGURATION
# ----------------------------------------------------------------------------------------------------------------------
COPY --chown=node:node ./docker/app/local/etc /etc
COPY --chown=node:node ./docker/app/local/usr /usr

# ----------------------------------------------------------------------------------------------------------------------
# PERMISSIONS FIX
# ----------------------------------------------------------------------------------------------------------------------
# Change USER_ID and GROUP_ID for nonroot container user if needed and install mysql-client
#
### Copy configuration files in to the container
COPY --chown=node:node docker/app/local/bin /usr/local/bin/
COPY --chown=node:node docker/app/local/etc /etc
#
### Change USER_ID and GROUP_ID for nonroot container user if needed
USER root
RUN fix-user ${DOCKER_USER} node ${DOCKER_USER_ID} ${DOCKER_GROUP_ID}

# ----------------------------------------------------------------------------------------------------------------------
# RUN
# Run setup and entrypoint start
# ----------------------------------------------------------------------------------------------------------------------
WORKDIR /var/www/html
#
### Basic user setup and start
USER node

EXPOSE 3005 8080

# Start
CMD ["start-command"]
35 changes: 0 additions & 35 deletions docker/app/local/etc/nginx/conf.d/default.conf

This file was deleted.

39 changes: 0 additions & 39 deletions docker/app/local/etc/nginx/nginx.conf

This file was deleted.

13 changes: 0 additions & 13 deletions docker/app/local/etc/supervisor/conf.d/nginx.conf

This file was deleted.

23 changes: 0 additions & 23 deletions docker/app/local/etc/supervisor/supervisord.conf

This file was deleted.

Loading
Loading