-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker implementation and documentation (#65)
- Loading branch information
Showing
11 changed files
with
647 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM node:8 | ||
LABEL maintainer "Nitin Goyal <[email protected]>, Luke Busstra <[email protected]>" | ||
|
||
ENV NGINX_CODENAME stretch | ||
ENV API_PORT 3001 | ||
|
||
# install requirements | ||
RUN echo "deb http://nginx.org/packages/debian/ ${NGINX_CODENAME} nginx" >> /etc/apt/sources.list \ | ||
&& apt-get update && apt-get install --no-install-recommends --no-install-suggests -y --assume-yes --allow-unauthenticated \ | ||
gettext-base\ | ||
bash \ | ||
zip \ | ||
unzip \ | ||
wget \ | ||
curl \ | ||
nano \ | ||
ca-certificates \ | ||
nginx \ | ||
nginx-module-image-filter | ||
|
||
# install PM2 | ||
RUN npm install pm2 -g | ||
|
||
RUN mkdir -p /var/www \ | ||
&& cd /var/www \ | ||
&& mkdir -p cezerin2 | ||
|
||
# download project | ||
ADD . /var/www/cezerin2 | ||
|
||
# Nginx config | ||
COPY nginx/nginx.conf /etc/nginx/ | ||
COPY nginx/default.conf.template /etc/nginx/conf.d/ | ||
|
||
# script to run Nginx and PM2 | ||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x "/usr/local/bin/docker-entrypoint.sh" | ||
|
||
# build project | ||
RUN cd /var/www/cezerin2 \ | ||
&& npm i | ||
|
||
WORKDIR /var/www/cezerin2 | ||
|
||
EXPOSE 80 | ||
|
||
# start PM2 | ||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
envsubst '${API_PORT}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf | ||
|
||
nginx | ||
exec pm2 start process.json --no-daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Single Instance cezerin2 dockerfile and docker-entrypoint.sh | ||
|
||
* [dockerfile](#dockerfile) | ||
* [docker-entrypoint.sh](#docker-entrypoint.sh) | ||
|
||
## dockerfile | ||
```docker-compose | ||
version: '3' | ||
services: | ||
api: | ||
build: | ||
context: ./cezerin2 | ||
env_file: .env | ||
environment: | ||
- DB_HOST=db | ||
- STORE_URL=http://www.exampe.com | ||
- API_BASE_URL=http://api.example.com/api/v1 | ||
- AJAX_BASE_URL=http://api.example.com/ajax | ||
- ASSETS_BASE_URL=http://asset.example.com | ||
- ADMIN_BASE_URL=http://admin.example.com | ||
ports: | ||
- 3001:80 | ||
volumes: | ||
- ./cezerin2/public/content:/var/www/cezerin2/public/content | ||
depends_on: | ||
- db | ||
restart: always | ||
store: | ||
build: | ||
context: ./cezerin2-store | ||
environment: | ||
- API_BASE_URL=http://api.example.com/api/v1 | ||
- AJAX_BASE_URL=http://api.example.com/ajax | ||
ports: | ||
- 3000:80 | ||
depends_on: | ||
- db | ||
- api | ||
restart: always | ||
admin: | ||
build: | ||
context: ./cezerin2-admin | ||
environment: | ||
- API_BASE_URL=http://api.example.com/api/v1 | ||
- API_WEB_SOCKET_URL=ws://api.example.com | ||
ports: | ||
- 3002:80 | ||
depends_on: | ||
- db | ||
- api | ||
restart: always | ||
proxy: | ||
build: | ||
context: ./proxy | ||
environment: | ||
- DOMAIN=example.com | ||
- STORE_HOST=store | ||
- ADMIN_HOST=admin | ||
- API_HOST=api | ||
ports: | ||
- 80:80 | ||
depends_on: | ||
- db | ||
- api | ||
- admin | ||
restart: always | ||
db: | ||
image: mongo:3.4 | ||
ports: | ||
- 27017:27017 | ||
volumes: | ||
- ./db:/data/db | ||
restart: always | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Single Instance cezerin2-proxy dockerfile and docker-entrypoint.sh | ||
|
||
* [dockerfile](#dockerfile) | ||
* [docker-entrypoint.sh](#docker-entrypoint.sh) | ||
|
||
## dockerfile | ||
```dockerfile | ||
FROM node:8 | ||
LABEL maintainer "Luke Busstra <[email protected]>" | ||
|
||
ENV NGINX_CODENAME stretch | ||
|
||
|
||
# install requirements and NGINX | ||
RUN echo "deb http://nginx.org/packages/debian/ ${NGINX_CODENAME} nginx" >> /etc/apt/sources.list \ | ||
&& apt-get update && apt-get install --no-install-recommends --no-install-suggests -y --force-yes \ | ||
gettext-base\ | ||
bash \ | ||
zip \ | ||
unzip \ | ||
wget \ | ||
curl \ | ||
nano \ | ||
ca-certificates \ | ||
nginx \ | ||
nginx-module-image-filter | ||
|
||
# Nginx config | ||
COPY nginx/nginx.conf /etc/nginx/ | ||
COPY nginx/default.conf.template /etc/nginx/conf.d/ | ||
|
||
# script to run Nginx and PM2 | ||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x "/usr/local/bin/docker-entrypoint.sh" | ||
|
||
EXPOSE 80 | ||
|
||
# start env build and Nginx | ||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | ||
``` | ||
|
||
## docker-entrypoint.sh | ||
```shell | ||
#!/bin/sh | ||
set -e | ||
|
||
envsubst '${DOMAIN} ${STORE_HOST} ${ADMIN_HOST} ${API_HOST} ${ASSET_HOST}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf | ||
|
||
nginx -g "daemon off;" | ||
``` |
Oops, something went wrong.