first draft booting with strapi, mongo, nginx
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
FROM nginx:latest
|
||||
|
||||
COPY ./default.conf /etc/nginx/conf.d/default.conf
|
||||
@@ -0,0 +1,26 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
root /var/www/html;
|
||||
index index.html;
|
||||
server_name *.figureslibres.cc;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
access_log on;
|
||||
error_log /var/log/nginx/error.log error;
|
||||
|
||||
sendfile off;
|
||||
|
||||
client_max_body_size 100m;
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
FROM node:11.1.0-alpine
|
||||
|
||||
WORKDIR /usr/src/api
|
||||
|
||||
RUN echo "unsafe-perm = true" >> ~/.npmrc
|
||||
|
||||
RUN npm install -g strapi@3.0.0-alpha.16
|
||||
|
||||
COPY strapi.sh ./
|
||||
RUN chmod +x ./strapi.sh
|
||||
|
||||
EXPOSE 1337
|
||||
|
||||
COPY healthcheck.js ./
|
||||
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \
|
||||
CMD node /usr/src/api/healthcheck.js
|
||||
|
||||
CMD ["./strapi.sh"]
|
||||
@@ -0,0 +1,25 @@
|
||||
const http = require("http");
|
||||
|
||||
const options = {
|
||||
host : "localhost",
|
||||
port : "1337",
|
||||
path: "/_health",
|
||||
method: "HEAD",
|
||||
timeout : 2000
|
||||
};
|
||||
|
||||
const request = http.get(options, (res) => {
|
||||
console.log(`STATUS: ${res.statusCode}`);
|
||||
if (res.statusCode == 204) {
|
||||
process.exit(0);
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
request.on('error', function(err) {
|
||||
console.error(`ERROR: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
request.end();
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
set -ea
|
||||
|
||||
_stopStrapi() {
|
||||
echo "Stopping strapi"
|
||||
kill -SIGINT "$strapiPID"
|
||||
wait "$strapiPID"
|
||||
}
|
||||
|
||||
trap _stopStrapi SIGTERM SIGINT
|
||||
|
||||
cd /usr/src/api
|
||||
|
||||
APP_NAME=${APP_NAME:-strapi-app}
|
||||
DATABASE_CLIENT=${DATABASE_CLIENT:-mongo}
|
||||
DATABASE_HOST=${DATABASE_HOST:-localhost}
|
||||
DATABASE_PORT=${DATABASE_PORT:-27017}
|
||||
DATABASE_NAME=${DATABASE_NAME:-strapi}
|
||||
|
||||
if [ ! -f "$APP_NAME/package.json" ]
|
||||
then
|
||||
strapi new ${APP_NAME} --dbclient=$DATABASE_CLIENT --dbhost=$DATABASE_HOST --dbport=$DATABASE_PORT --dbname=$DATABASE_NAME --dbusername=$DATABASE_USERNAME --dbpassword=$DATABASE_PASSWORD --dbssl=$DATABASE_SSL --dbauth=$DATABASE_AUTHENTICATION_DATABASE
|
||||
elif [ ! -d "$APP_NAME/node_modules" ]
|
||||
then
|
||||
npm install --prefix ./$APP_NAME
|
||||
fi
|
||||
|
||||
cd $APP_NAME
|
||||
strapi start &
|
||||
|
||||
strapiPID=$!
|
||||
wait "$strapiPID"
|
||||
Reference in New Issue
Block a user