Skip to content

Commit

Permalink
update dockerfile, change njs to version 0.8.0, cleaning project
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Werfling committed Sep 12, 2023
1 parent 1f76d6f commit 8890373
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.nginxsrc
file: ./Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta_flyingfish.outputs.tags }}
Expand Down
206 changes: 166 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,69 +1,195 @@
FROM node:18-bullseye

ENV FLYINGFISH_NGINX_MODULE_MODE_DYN "1"
ENV FLYINGFISH_NGINX_MODULE_MODE_DYN "0"

ARG NGINX_VERSION=1.22.1
ARG HEADERS_MORE_VERSION=v0.34
ARG NJS_BRANCH=0.8.0

RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y dublin-traceroute
RUN apt-get install -y iputils-ping
RUN apt-get install -y openssl
RUN apt-get install -y curl gnupg2 ca-certificates lsb-release debian-archive-keyring
#RUN apk add --upgrade paris-traceroute

RUN curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

RUN echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx" \
| tee /etc/apt/sources.list.d/nginx.list
RUN apt install -y python3-pip python3-dev
RUN apt install -y git

RUN apt-get remove -y nginx nginx-common
RUN cd ~ && wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && tar -zxvf nginx-$NGINX_VERSION.tar.gz
RUN apt update -y
RUN apt-get upgrade -y
RUN apt install -y nginx nginx-module-njs nginx-module-njs-dbg
RUN apt-get install -y build-essential
RUN apt-get install -y libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
RUN apt-get install -y mercurial
RUN cd ~ && \
git clone --depth 1 --branch $NJS_BRANCH https://github.com/nginx/njs.git && \
cd ~/njs && \
./configure && \
make

RUN cd ~ && \
git clone --depth 1 -b $HEADERS_MORE_VERSION --single-branch https://github.com/openresty/headers-more-nginx-module.git \
&& cd ~/headers-more-nginx-module \
&& git submodule update --init

RUN cd ~/nginx-$NGINX_VERSION && \
./configure \
--sbin-path=/usr/bin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-pcre \
--pid-path=/var/run/nginx.pid \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-http_secure_link_module \
--add-module=../njs/nginx \
--add-module=../headers-more-nginx-module/ \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--modules-path=/usr/lib/nginx/modules/ &&\
make && \
make install

RUN apt install -y python3-pip python3-dev
RUN apt install -y git
RUN pip3 install pip --upgrade
RUN pip3 install certbot-nginx
RUN mkdir /etc/letsencrypt

RUN mkdir -p /opt/app
RUN mkdir -p /opt/app/frontend
RUN mkdir -p /opt/app/nginx
RUN mkdir -p /opt/app/nginx/body
RUN mkdir -p /opt/app/nginx/logs
RUN mkdir -p /opt/app/nginx/servers
RUN mkdir -p /opt/app/nginx/servers/logs
RUN mkdir -p /opt/app/nginx/html
RUN mkdir -p /var/log/flyingfish/
# Init App dirs --------------------------------------------------------------------------------------------------------
RUN mkdir -p /opt/flyingfish
RUN mkdir -p /opt/flyingfish/schemas
RUN mkdir -p /opt/flyingfish/core
RUN mkdir -p /opt/flyingfish/backend
RUN mkdir -p /opt/flyingfish/frontend
RUN mkdir -p /opt/flyingfish/nginx
RUN mkdir -p /opt/flyingfish/nginx/html
RUN mkdir -p /var/log/flyingfish
RUN mkdir -p /var/lib/flyingfish

WORKDIR /opt/app
# Copy/Install Schemas ----------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish/schemas

COPY ./schemas/ ./

RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true

RUN npm install
RUN npm run build

# Copy/Install Core ----------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish/core

COPY ./core/ ./

RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true

RUN npm install
RUN npm run build

# Copy/Install DemoPlugin ----------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish/demoplugin

COPY core ./../core
COPY backend/dist ./dist
COPY backend/node_modules ./node_modules
COPY backend/package.json ./package.json
COPY ./demoplugin/ ./

COPY frontend/assets ./frontend/assets
COPY frontend/images ./frontend/images
COPY frontend/dist ./frontend/dist
COPY frontend/src ./frontend/src
COPY frontend/index.html ./frontend/index.html
COPY frontend/login.html ./frontend/login.html
COPY frontend/manifest.json ./frontend/manifest.json
COPY frontend/package.json ./frontend/package.json
RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true

COPY nginx/dist ./nginx/dist
COPY nginx/node_modules ./nginx/node_modules
COPY nginx/pages ./nginx/pages
COPY nginx/htpasswd ./nginx/htpasswd
COPY nginx/package.json ./nginx/package.json
RUN npm install
RUN npm run build

# Copy/Install Backend -------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish/backend

COPY backend ./

RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true

RUN npm install
RUN npm run build

# Copy/Install Frontend ------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish/frontend

COPY frontend ./
RUN rm -R ./node_modules | true
RUN rm -R ./dist | true
RUN rm ./package-lock.json | true

RUN npm install --force
RUN npm run gulp-clone-bambooo
RUN npm run gulp-copy-data
RUN npm run gulp-build-webpack

# Copy/Install nginx ---------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish/nginx

COPY nginx ./
RUN rm -R ./node_modules | true
RUN rm -R ./dist | true
RUN rm -R ./logs | true
RUN rm -R ./body | true
RUN rm -R ./sample | true
RUN rm -R ./servers | true
RUN rm ./package-lock.json | true
RUN rm ./nginx.pid | true
RUN rm ./dhparam.pem | true
RUN rm nginx.conf | true

RUN mkdir /opt/flyingfish/nginx/servers
RUN mkdir /opt/flyingfish/nginx/servers/proxy_temp
RUN chmod 700 /opt/flyingfish/nginx/servers/proxy_temp
RUN mkdir /opt/flyingfish/nginx/logs
RUN chmod 755 /opt/flyingfish/nginx/logs

RUN npm install

# add supervisor -------------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish

RUN npm install supervisor -g

# defaults ports -------------------------------------------------------------------------------------------------------

EXPOSE 80
EXPOSE 443
EXPOSE 3000

CMD [ "node", "dist/main.js", "--envargs=1"]
# start main app -------------------------------------------------------------------------------------------------------

WORKDIR /opt/flyingfish

CMD [ "node", "backend/dist/main.js", "--envargs=1"]
Loading

0 comments on commit 8890373

Please sign in to comment.