Skip to content

Commit

Permalink
Make multistage docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
jekkos committed Mar 6, 2020
1 parent f3e87d3 commit 7d94ba7
Show file tree
Hide file tree
Showing 12 changed files with 1,636 additions and 79 deletions.
22 changes: 20 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.3-apache
FROM php:7.3-apache AS ospos
MAINTAINER jekkos

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
Expand All @@ -16,4 +16,22 @@ COPY . /app
RUN ln -s /app/*[^public] /var/www && rm -rf /var/www/html && ln -nsf /app/public /var/www/html
RUN chmod 755 /app/public/uploads && chown -R www-data:www-data /app/public /app/application

RUN [ ! -f test/ospos.js ] || sed -i -e "s/\(localhost\)/web/g" test/ospos.js
FROM ospos AS ospos_test

COPY --from=composer /usr/bin/composer /usr/bin/composer

RUN composer install -d/app
RUN php /app/vendor/kenjis/ci-phpunit-test/install.php -a /app/application -p /app/vendor/codeigniter/framework

WORKDIR /app/application/tests

CMD ["/app/vendor/phpunit/phpunit/phpunit"]

FROM ospos AS ospos_dev

RUN mkdir -p /app/bower_components && ln -s /app/bower_components /var/www/html/bower_components
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini

9 changes: 0 additions & 9 deletions Dockerfile.dev

This file was deleted.

11 changes: 0 additions & 11 deletions Dockerfile.test

This file was deleted.

20 changes: 19 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,25 @@ module.exports = function(grunt) {
archive: 'dist/opensourcepos.zip'
},
files: [
{src: ['public/**', 'vendor/**', 'application/**', '!/public/images/menubar/png/', '!/public/dist/bootswatch/', '/public/dist/bootswatch/*/*.css', 'database/**', '*.txt', '*.md', 'LICENSE', 'docker*', 'Dockerfile', '**/.htaccess', '*.csv']}
{
src: [
'public/**',
'vendor/**',
'application/**',
'!/application/tests',
'!/public/images/menubar/png/',
'!/public/dist/bootswatch/',
'/public/dist/bootswatch/*/*.css',
'database/**',
'*.txt',
'*.md',
'LICENSE',
'docker*',
'Dockerfile',
'**/.htaccess',
'*.csv'
]
}
]
}
}
Expand Down
1 change: 1 addition & 0 deletions application/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_ci_phpunit_test/tmp/
46 changes: 46 additions & 0 deletions application/tests/libraries/Barcode_lib_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

class Barcode_lib_test extends UnitTestCase
{
public function setUp()
{
$this->resetInstance();

$this->obj = $this->newLibrary('Barcode_lib');
}

public function test_barcode_weight_first()
{
$config = $this->getMockBuilder('CI_Config')
->disableOriginalConstructor()
->setMethods(['item'])
->getMock();
$config->method('item')
->willReturn("02(\d{5})(\w{6})");

$item_number = "025000abcdef";
$quantity = 0;
$this->obj->parse_barcode_fields($quantity, $item_number);

echo $quantity;
$this->assertEquals($quantity, 1);
$this->assertEquals($item_number, "025000123456");
}

public function test_barcode_weight_last()
{
$config = $this->getMockBuilder('CI_Config')
->disableOriginalConstructor()
->setMethods(['item'])
->getMock();
$config->method('item')
->willReturn("02(\w{6})(\d{5})");

$item_number = "0212345650001";
$quantity = 0;
$this->obj->parse_barcode_fields($quantity, $item_number);

$this->assertEquals($quantity, 5.001);
$this->assertEquals($item_number, 123456);
}
}
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"POS"
],
"homepage": "https://github.com/opensourcepos/opensourcepos",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/kenjis/ci-phpunit-test"
}
],
"require": {
"php": "^5.6 || ^7.0",
"codeigniter/framework": "^3.1.11",
Expand All @@ -25,6 +31,8 @@
"vlucas/phpdotenv": "^2.4"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*"
"mikey179/vfsstream": "1.1.*",
"phpunit/phpunit": "7.5.6",
"kenjis/ci-phpunit-test": "dev-master"
}
}
Loading

0 comments on commit 7d94ba7

Please sign in to comment.