Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented dockerfiles for frontend, fixed some issues with local build scripts #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
57 changes: 57 additions & 0 deletions docker/Dockerfile-ecas-frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM php:7.2-apache

# Add the necessary libraries and extensions to PHP
RUN apt-get update \
&& apt-get install -y \
libmcrypt-dev \
curl \
git \
zip \
unzip \
default-mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install zip
RUN pecl install mcrypt-1.0.5 \
&& docker-php-ext-enable mcrypt
#RUN npm i -g npm
# Set the documet root
ENV APACHE_DOCUMENT_ROOT /web-app/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

# Enable mod_rewrite module to make our urls work
RUN a2enmod rewrite

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer


RUN mkdir /web-app


WORKDIR /web-app

COPY ./web-app ./
RUN rm -rf public/css/* public/js/* bootstrap/cache/*

RUN composer install

USER root


RUN chmod -R go+w ./storage
RUN chmod -R go+w ./bootstrap/cache


RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN apt-get update \
&& apt-get install -y software-properties-common npm libavahi-compat-libdnssd-dev ssh
RUN service apache2 restart
RUN npm cache clean --force\
&& npm install \
&& npm run dev




8 changes: 7 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
1. Have a working installation of [Docker](https://www.docker.com/)
2. Use a shell such as `bash` ( or [Git bash](https://git-scm.com/downloads) if on Windows)
3. Have the [S2I binaries](https://github.com/openshift/source-to-image/releases) on your path
3. Get Red Hat credentials or Register for a Red Hat account if you don't have those credentials available.
4. Login to Red Hat registery using this command: docker login https://registry.redhat.io. You will get prompted for the credentials from step 3.
5. Copy env.sample to .env and add required secrets

## Running the project
The `manage` script in this directory contains a set of utilities that help getting up and running in Docker in no time. The command `./manage --help` can be run at any time to read the usage instructions.
Expand All @@ -14,4 +17,7 @@ To run the project execute `./manage start`: the api container will be serving c

### Development Mode
During development it is useful to have code hot-reloading enabled, so that containers won't need to be rebuilt after each change.
To start both the api and frontend container in development mode, using code hot-reloading, run `./manage start-dev`.
To start both the api and frontend container in development mode, using code hot-reloading, run `./manage start-dev`.

### Build from dockerfiles
run ./build-from-dockerfiles
8 changes: 8 additions & 0 deletions docker/build-from-dockerfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
#cleanup volumes before starting docker compose
docker-compose -f docker-compose-local.yml down --volumes
cp ../web-app/.env .env
# build ecas-api and cas-api. For now only frontend is built from dockerfiles
./manage build api
./manage build cas-api
docker-compose -f docker-compose-local.yml up --build
20 changes: 2 additions & 18 deletions docker/docker-compose.yml → docker/docker-compose-S2I.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ services:
- 7070:8080
networks:
- webnet

environment:
- APP_KEY=base64:sf+TeOK14bHa/pqupMwHbV5MUBFeZF/OPFh+LU++0w8=
- APP_KEY=${APP_KEY_BASE64}
- APP_DEBUG=true
- APP_URL=http://localhost
- DOCUMENTROOT=/public
Expand All @@ -34,23 +35,6 @@ services:
networks:
- webnet

# # ecas-frontend-dev
# #
# ecas-frontend-dev:
# build:
# context: ..
# dockerfile: docker/ecas-frontend/Dockerfile-dev
# working_dir: /web-app
# ports:
# - 8081:80
# volumes:
# - ../web-app:/web-app
# networks:
# - webnet
# environment:
# - CHOKIDAR_USEPOLLING=true
# - APP_KEY=base64:sf+TeOK14bHa/pqupMwHbV5MUBFeZF/OPFh+LU++0w8=
# - APP_DEBUG=true

networks:
webnet:
64 changes: 64 additions & 0 deletions docker/docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: '3'
services:

# ecas-frontend
# DYNAMICSBASEURL=https://ecaswebapi.azurewebsites.net/api
ecas-frontend:
build:
context: ..
dockerfile: docker/Dockerfile-ecas-frontend
working_dir: /web-app
ports:
- 7070:80

networks:
- webnet
volumes:
- ../web-app:/web-app
- /web-app/vendor
- /web-app/node_modules
- /web-app/storage
- /web-app/bootstrap/cache
- /web-app/public

environment:
- APP_KEY=${APP_KEY_BASE64}
- APP_DEBUG=true
- APP_URL=http://localhost
- DOCUMENTROOT=/public
- DYNAMICSBASEURL=${DYNAMICSBASEURL:-http://ecas-api:8080/api}



# ecas-api
#
ecas-api:
image: ecas-api
ports:
- 8080:8080
networks:
- webnet

# cas-api
#
cas-api:
image: cas-api
ports:
- 8081:8080
networks:
- webnet


networks:
webnet:
volumes:
web-app-vendor:
driver: local
web-app-storage:
driver: local
web-app-cache:
driver: local
web-app-node:
driver: local
web-app-public:
driver: local
20 changes: 12 additions & 8 deletions docker/manage
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ build-ecas-frontend() {
#
BASE_IMAGE="registry.redhat.io/rhscl/php-73-rhel7"
echo -e "\nBuilding ecas-frontend image from ${BASE_IMAGE}..."
docker pull ${BASE_IMAGE}

${S2I_EXE} build \
'../web-app' \
Expand All @@ -92,8 +93,10 @@ build-ecas-api() {
#
# ecas-api
#
BASE_IMAGE="mcr.microsoft.com/dotnet/aspnet:6.0"
BASE_IMAGE="registry.redhat.io/rhel8/dotnet-60"
echo -e "\nBuilding ecas-api image from ${BASE_IMAGE}..."
docker pull ${BASE_IMAGE}


${S2I_EXE} build \
'../web-api/Ecas.Dyn365Service' \
Expand All @@ -109,6 +112,7 @@ build-ecas-cas-api() {
DOTNET_STARTUP_PROJECT=CASInterfaceService/cas-interface-service.csproj
BASE_IMAGE="registry.redhat.io/dotnet/dotnet-21-rhel7"
echo -e "\nBuilding cas-api image from ${BASE_IMAGE}..."
docker pull ${BASE_IMAGE}

${S2I_EXE} build \
-e "DOTNET_STARTUP_PROJECT=${DOTNET_STARTUP_PROJECT}" \
Expand All @@ -120,6 +124,8 @@ build-ecas-cas-api() {
build-ecas-all() {
build-ecas-frontend
build-ecas-api
build-ecas-cas-api

}

configureEnvironment() {
Expand Down Expand Up @@ -216,22 +222,20 @@ case "${COMMAND}" in
start|up)
unset DEBUG
DEFAULT_CONTAINERS="ecas-frontend $DEFAULT_CONTAINERS"
_startupParams=$(getStartupParams $@)
configureEnvironment $@
docker-compose up -d ${_startupParams}
docker-compose logs -f
docker-compose -f docker-compose-S2I.yml up -d
docker-compose logs -f docker-compose-S2I.yml
;;
start-dev)
export DEBUG=true
DEFAULT_CONTAINERS="ecas-frontend"
_startupParams=$(getStartupParams $@)
configureEnvironment $@
docker-compose up -d ${_startupParams}
docker-compose logs -f
docker-compose -f docker-compose-S2I.yml up -d
docker-compose logs -f docker-compose-S2I.yml
;;
logs)
configureEnvironment $@
docker-compose logs -f
docker-compose logs -f docker-compose-S2I.yml
;;
stop)
DEFAULT_CONTAINERS="ecas-frontend ecas-frontend-dev"
Expand Down
1 change: 1 addition & 0 deletions web-app/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://ecas.test
APP_KEY_BASE64=

DYNAMICSBASEURL=
DYNAMICS_TIMEOUT=30
Expand Down
2 changes: 1 addition & 1 deletion web-app/webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ const mix = require('laravel-mix');
*/

mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
.sass('resources/sass/app.scss', 'public/css').version();

mix.js('node_modules/popper.js/dist/popper.js', 'public/js').sourceMaps();