Skip to content

Commit

Permalink
Merge pull request #31 from pryv/release/1.9.0
Browse files Browse the repository at this point in the history
Release/1.9.0
  • Loading branch information
perki authored Dec 20, 2023
2 parents 4e2d444 + eb105b1 commit 09f298a
Show file tree
Hide file tree
Showing 14 changed files with 1,323 additions and 820 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# commented ones are actually needed

.git
.github
.vscode
#build
node_modules
**/test
.gitignore
.eslintrc.yml
.licenser.yml
.mocharc.js
application.log
npm-debug.log
README.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ node_modules/
proxy/nginx.conf
service-mail.iml
npm-debug.log
build/test/pryv/mail/log/mail.log
40 changes: 23 additions & 17 deletions build/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@

set -e

# Determine the build_tag and whether we need to release.
SCRIPT_FOLDER=$(cd $(dirname "$0"); pwd)
cd ..


# Builds 'service-mail' docker image with the version given below.

# Determine the build_tag and whether we need to release.
scripts/build_name
version=$(cat build_tag)
build/scripts/build_name
if [ "$1" == "test" ]
then
version=test
host=localhost
release=false
else
version=$(cat build_tag)
host='eu.gcr.io'
release=true
fi

mkdir -p mail/bin
rsync -a ../ mail/bin \
--exclude node_modules \
--exclude .github \
--exclude build \
--exclude config \
--exclude test \
--exclude .gitignore \
--exclude .git

host='eu.gcr.io'

echo "---------------------------- building mail ------------------------------"
pushd mail
docker build -f Dockerfile -t $host/pryvio/mail:$version .
docker push $host/pryvio/mail:$version
popd
docker build -f build/mail/Dockerfile -t $host/pryvio/mail:$version .

if [ "$release" = true ]
then
docker push $host/pryvio/mail:$version
fi

25 changes: 11 additions & 14 deletions build/mail/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM eu.gcr.io/pryvio/base:1.8.1
MAINTAINER "Tech@Pryv" <[email protected]>

# mount build folder
ADD . /pd_build
RUN ls pd_build
FROM eu.gcr.io/pryvio/base:1.9.0
LABEL maintainer="Pryv<[email protected]>"

# Set main paths that will be reused in this docker file
ARG TARGET_DIR="/app/bin"
Expand All @@ -12,25 +8,27 @@ ARG LOG_DIR="/app/log"

# Create software dir
RUN mkdir -p $TARGET_DIR
RUN cp -a /pd_build/bin/. $TARGET_DIR
COPY ../../ $TARGET_DIR
RUN chown -R app $TARGET_DIR
RUN cd $TARGET_DIR && npm ci

# Install the config file
RUN mkdir -p $CONF_DIR
RUN cp /pd_build/config/mail.json $CONF_DIR/mail.json
COPY ./build/mail/config/mail.json $CONF_DIR/mail.json

# Create the log
RUN mkdir -p $LOG_DIR
RUN touch $LOG_DIR/mail.log && chown -R app:app $LOG_DIR

# Install the script that runs the api service
RUN mkdir /etc/service/mail
RUN cp /pd_build/runit/mail /etc/service/mail/run
COPY ./build/mail/runit/mail /etc/service/mail/run

WORKDIR $TARGET_DIR
RUN cd $TARGET_DIR; ls $TARGET_DIR
RUN npm ci



# Remove cron and sshd entirely, unless we use them
RUN rm -r /etc/service/cron
RUN rm -r /etc/service/sshd && rm /etc/my_init.d/00_regen_ssh_host_keys.sh

# Install sendmail
RUN ["/bin/bash", "-c", "apt-get update && apt-get install -y --no-install-recommends sendmail"]
Expand All @@ -40,6 +38,5 @@ RUN apt-get remove -y autoconf automake
RUN apt-get autoremove
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN rm -rf /pd_build

EXPOSE 9000
7 changes: 5 additions & 2 deletions build/mail/config/mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"colorize": true
},
"file": {
"active": false
"active": true,
"level": "info",
"path": "/app/log/mail.log"
}
},
"email": {
Expand All @@ -34,6 +36,7 @@
"auth": "CHANGEME"
},
"templates": {
"defaultLang": "en"
"defaultLang": "en",
"root": "/app/bin/templates"
}
}
6 changes: 5 additions & 1 deletion build/mail/runit/mail
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ cd /app/bin
chown -R app:app /app/log/

# Setup sendmail (at startup because it depends on current container hostname)
echo "127.0.0.1 localhost localhost.localdomain $HOSTNAME" >> /etc/hosts && yes 'Y' | sendmailconfig
if node /app/bin/build/scripts/sendmail-test.js | grep "TRUE" -q; then
echo "127.0.0.1 localhost localhost.localdomain $HOSTNAME" >> /etc/hosts && yes 'Y' | sendmailconfig
else
echo "SKIPING sendmail"
fi

export NODE_ENV=production
export NODE_PATH=/app/bin/
Expand Down
2 changes: 2 additions & 0 deletions build/scripts/sendmail-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const config = require('/app/conf/mail.json');
console.log(config?.sendmail?.active ? "TRUE": "FALSE");
9 changes: 9 additions & 0 deletions build/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Local Docker containers

Tools to test Docker image builds.

Requires an AMD64 machine with Docker accessible at user level.

1. `./build/build test` to build test Docker images
2. `./build/test/start.sh` to run containers

14 changes: 14 additions & 0 deletions build/test/pryv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.5'
services:
mail:
image: "localhost/pryvio/mail:test"
container_name: pryvio_mail
ports:
- 9000:9000
volumes:
- ${PRYV_CONF_ROOT}/pryv/mail/conf/:/app/conf/:ro
- ${PRYV_CONF_ROOT}/../../templates/:/app/bin/templates/:ro
- ${PRYV_CONF_ROOT}/pryv/mail/log/:/app/log/
environment:
- HOSTNAME=$HOSTNAME
restart: always
31 changes: 31 additions & 0 deletions build/test/pryv/mail/conf/mail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"logs": {
"prefix": "",
"console": {
"active": true,
"level": "info",
"colorize": true
},
"file": {
"active": true,
"level": "info",
"path": "/app/log/mail.log"
}
},
"email": {
"message": {
"from": {"name":"Pryv","address":"[email protected]"}
}
},
"smtp": {"host":"mail.gandi.net","port":587,"auth":{"user":"[email protected]","pass":"wrzzjiwlktzkybdi"}},
"sendmail": {"active":false},
"http": {
"ip": "0.0.0.0",
"port": 9000,
"auth": "fdsuavfhdsvfhsd"
},
"templates": {
"defaultLang": "en",
"root": "/app/bin/templates/"
}
}
9 changes: 9 additions & 0 deletions build/test/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SCRIPT_FOLDER=$(cd $(dirname "$0"); pwd)

export PRYV_CONF_ROOT=$SCRIPT_FOLDER

# Create default directories
mkdir -p ${PRYV_CONF_ROOT}/pryv/mail/log
sudo chown -R 9999:9999 ${PRYV_CONF_ROOT}/pryv/mail/log

HOSTNAME=l.rec.la docker-compose -f ${PRYV_CONF_ROOT}/pryv.yml up
Loading

0 comments on commit 09f298a

Please sign in to comment.