Skip to content
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ You can <a href="https://twake.app"> try Twake</a> in SaaS.

Or run your own local Twake instance with :

```
cd twake
sudo ./start.sh
```bash
cd twake
export COMPOSE_FILE=docker-compose.onpremise.yml
docker compose up -d
```

Twake will be running on http//localhost and by default redirect to https and uses a self-signed certificate. If you want to run http only then set SSL_CERTS=none at docker-compose.yml
Expand Down
42 changes: 29 additions & 13 deletions twake/docker-compose.onpremise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,59 @@ services:
- 9042:9042
volumes:
- ./docker-data/scylladb:/var/lib/scylla
healthcheck:
test: ["CMD-SHELL", "nodetool status | grep UN"]
interval: 30s
timeout: 10s
retries: 3

rabbitmq:
image: rabbitmq:3
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
timeout: 10s
retries: 3

node:
image: twaketech/twake-node:2021.Q2.505
build:
context: .
dockerfile: docker/twake-node/Dockerfile
environment:
- NODE_ENV=production
- PUBSUB_URLS=amqp://guest:guest@rabbitmq:5672
volumes:
- ./configuration/backend-node/production.json:/usr/src/app/config/production.json
- ./default-configuration/backend-node/production.json:/usr/src/app/config/production.json
- ./docker-data/documents/:/storage/
depends_on:
- scylladb
- rabbitmq
links:
- scylladb
scylladb:
condition: service_healthy
rabbitmq:
condition: service_healthy

php:
image: twaketech/twake-php:2021.Q2.505
build:
context: .
dockerfile: docker/twake-php/Dockerfile
environment:
- DEV=production
volumes:
- ./configuration/backend/Parameters.php:/configuration/Parameters.php
- ./default-configuration/backend/Parameters.php:/configuration/Parameters.php
- ./connectors/:/twake-core/src/BuiltInConnectors/Connectors
- ./docker-data/drive/:/twake-core/drive/
- ./docker-data/fpm/:/etc/docker-data/fpm/
- ./docker-data/drive-preview/:/twake-core/web/medias/
- ./docker-data/uploads/:/twake-core/web/upload/
depends_on:
- scylladb
- rabbitmq
links:
- scylladb
scylladb:
condition: service_healthy
rabbitmq:
condition: service_healthy

nginx:
image: twaketech/twake-nginx:2021.Q2.505
build:
context: .
dockerfile: docker/twake-nginx/Dockerfile
environment:
- DEV=production
- SSL_CERTS=selfsigned
Expand Down
77 changes: 21 additions & 56 deletions twake/docker/twake-nginx/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,66 +1,31 @@
FROM debian:11
# First stage: building frontend
FROM node:lts AS build

RUN apt-get update && apt-get -y install cron

RUN apt-get update && apt-get install -y \
nginx

RUN apt-get update && apt-get install -y wget

RUN rm /etc/nginx/sites-enabled/default

RUN usermod -u 1000 www-data

RUN apt-get remove certbot
RUN apt-get install -y python3 python3-venv libaugeas0
RUN python3 -m venv /opt/certbot/
RUN /opt/certbot/bin/pip install --upgrade pip
RUN /opt/certbot/bin/pip install certbot
RUN ln -s /opt/certbot/bin/certbot /usr/bin/certbot

ADD docker/twake-nginx/nginx.conf /etc/nginx/nginx.conf

# Install yarn
RUN apt-get update
RUN apt-get -y install curl
RUN apt-get -y install apt-transport-https ca-certificates apt-utils gnupg
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get -y install yarn
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
RUN yarn global add webpack
RUN yarn global add webpack-cli
RUN apt-get update
RUN apt-get -y install git

# Install frontend
RUN yarn global add webpack webpack-cli
COPY frontend /twake-react/

WORKDIR /twake-react/

ADD docker/twake-nginx/site.conf /etc/nginx/sites-available/site.template
ADD docker/twake-nginx/redirect.conf /etc/nginx/sites-available/redirect
ADD docker/twake-nginx-php-only/nginx.conf /etc/nginx/nginx.conf
RUN apt-get update && apt-get install gettext-base
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf

COPY frontend /twake-react/
RUN cp /twake-react/src/app/environment/environment.ts.dist /twake-react/src/app/environment/environment.ts
RUN yarn install --network-timeout 1000000000
ENV GENERATE_SOURCEMAP false
RUN cat /twake-react/src/app/environment/environment.ts.dist
RUN cat /twake-react/src/app/environment/environment.ts
ENV GENERATE_SOURCEMAP=false
RUN yarn build
RUN rm -R node_modules

RUN cp /twake-react/src/app/environment/environment.ts.dist /environment.ts.dist

RUN cp /twake-react/src/app/environment/environment.ts.dist /twake-react/src/app/environment/environment.ts && \
yarn install --network-timeout 1000000000 && \
# cat /twake-react/src/app/environment/environment.ts.dist && \
# cat /twake-react/src/app/environment/environment.ts && \
yarn build && \
rm -rf node_modules

# Second stage: configuring nginx and copying build artifacts
FROM nginx:latest
COPY docker/twake-nginx/nginx.conf /etc/nginx/nginx.conf
COPY docker/twake-nginx/site.conf /etc/nginx/sites-available/site.template
COPY docker/twake-nginx/redirect.conf /etc/nginx/sites-available/redirect
COPY docker/twake-nginx/entrypoint.sh /
COPY docker/twake-nginx/self-signed.sh /usr/local/bin/
RUN chmod 0777 /entrypoint.sh
ENTRYPOINT /entrypoint.sh "$DEV"
COPY --from=build /twake-react /twake-react

RUN chmod +x /entrypoint.sh && rm /etc/nginx/conf.d/default.conf

ENTRYPOINT ["/entrypoint.sh", "$DEV"]

EXPOSE 80
EXPOSE 443
8 changes: 2 additions & 6 deletions twake/docker/twake-nginx/entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ else
fi
fi

[[ -d "/etc/nginx/sites-enabled" ]] || mkdir /etc/nginx/sites-enabled

function _selfsigned() {
self-signed.sh
export NGINX_LISTEN="443 ssl"
Expand Down Expand Up @@ -43,10 +45,4 @@ export PHP_UPSTREAM
envsubst '$${NODE_HOST} $${NGINX_LISTEN}' < /etc/nginx/sites-available/site.template > /etc/nginx/sites-enabled/site
echo "upstream php-upstream { server ${PHP_UPSTREAM}; }" > /etc/nginx/conf.d/upstream.conf

# Symlink stdout and stderr to logs file for docker log collector
# See https://github.com/nginxinc/docker-nginx/blob/456bf337ceb922a207651aa7c6077a316c3e368c/mainline/debian/Dockerfile#L99-L100
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log

cron -f &
nginx -g "daemon off;"
74 changes: 30 additions & 44 deletions twake/docker/twake-node/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
# Common node machine
FROM node:16-bullseye-slim as node-base
FROM node:lts as node-base

### Install dependancies

#Imagick
RUN apt-get update && apt-get install -y ghostscript && apt-get clean
RUN apt-get update && apt-get install -y graphicsmagick

#Unoconv
RUN apt-get update && apt-get install -y --force-yes unoconv libxml2-dev
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && apt-get install wget
# upgrade unoconv
RUN wget -N https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv -O /usr/bin/unoconv
RUN chmod ugo+x /usr/bin/unoconv
RUN ln -s /usr/bin/python3 /usr/bin/python

RUN apt-get update && \
apt-get install -y ghostscript graphicsmagick wget unoconv libxml2-dev ffmpeg python-is-python3 && \
# upgrade unoconv
wget -N https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv -O /usr/bin/unoconv && \
chmod +x /usr/bin/unoconv
#Docker mac issue
RUN apt-get update && apt-get install -y libc6
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
# RUN apt-get update && apt-get install -y libc6
# RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

# FFmpeg
RUN apt-get install -y ffmpeg

### Install Twake

Expand All @@ -37,42 +26,39 @@ COPY backend/node/ .
# Add frontend Stage
FROM node-base as with-frontend

ARG NODE_ENV=production

ENV NODE_ENV=development
RUN npm install #Install dev dependancies for build
COPY backend/node/ .
ENV NODE_ENV=${NODE_ENV}
RUN npm run build #Build in production mode
RUN rm -R node_modules
RUN npm install #Install prod dependancies after build
#Install dev dependancies for build
RUN NODE_ENV=development npm install && \
#Build in production mode
export NODE_ENV=production && \
npm run build && \
rm -rf node_modules && \
#Install prod dependancies after build
npm install --legacy-peer-deps

# Add frontend into node
ENV NODE_ENV=development
COPY frontend/ ../public_build/
RUN apt-get install -y build-essential
RUN cd ../public_build && yarn install --network-timeout 1000000000
RUN yarn global add webpack && yarn global add webpack-cli && yarn global add jest
RUN cp ../public_build/src/app/environment/environment.ts.dist ../public_build/src/app/environment/environment.ts
ENV NODE_ENV=${NODE_ENV}
RUN cd ../public_build && yarn build
RUN cd ../public_build && rm -R node_modules
RUN mv ../public_build/build/* public/; rm -R ../public_build
RUN export NODE_ENV=development && \
apt-get install -y build-essential && \
cd ../public_build/ && \
yarn install --network-timeout 1000000000 && \
yarn global add webpack webpack-cli jest && \
cp src/app/environment/environment.ts.dist src/app/environment/environment.ts && \
export NODE_ENV=production && \
yarn build && \
rm -R node_modules && \
mv build/* ../app/public && \
cd .. && rm -R public_build/

# Development Stage
FROM with-frontend as development

ENV NODE_ENV=development
RUN npm install -g pino-pretty
RUN npm install -g tsc-watch
RUN yarn install
RUN ls
RUN ls public

RUN npm install -g pino-pretty && \
npm install -g tsc-watch && \
yarn install
CMD ["npm", "run", "dev:debug"]



# Production Stage
FROM with-frontend as production

Expand Down
16 changes: 7 additions & 9 deletions twake/docker/twake-php/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
FROM twaketech/php7.1-cassandra

MAINTAINER Romaric Mourgues <romaric.mourgues@twakeapp.com>
LABEL org.opencontainers.image.authors="Romaric Mourgues <romaric.mourgues@twakeapp.com>,Nguyen Thai <tknguyen@linagora.com>"

#Crontab
ADD docker/twake-php/crontab /etc/cron.d/twake-cron
RUN chmod 0644 /etc/cron.d/twake-cron
RUN touch /var/log/cron.log

RUN mkdir /twake-core/
COPY backend/core/ /twake-core/
RUN cd /twake-core/ && php composer.phar install

COPY docker/twake-php/entrypoint.sh /
RUN chmod 0777 /entrypoint.sh

RUN chmod 0644 /etc/cron.d/twake-cron && \
touch /var/log/cron.log && \
cd /twake-core/ && php composer.phar install && \
chmod +x /entrypoint.sh

#For exec
WORKDIR /twake-core/

ENTRYPOINT /entrypoint.sh "$DEV"
ENTRYPOINT ["/entrypoint.sh", "$DEV"]