Skip to content

Commit

Permalink
Simplify local Docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Feb 28, 2019
1 parent 4a40095 commit 6d2b2f4
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 52 deletions.
20 changes: 13 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
.dockerignore
.vagrant
.idea
data/*
Makefile
.*.yml
*.yml
*.js
.DS_Store
.htaccess
*.lock
*.md
*.js
*.sh
app.json
.*.yml
*.yml
data/*
plugins/*
tests
ChangeLog
composer.json
Dockerfile
Makefile
package.json
Vagrantfile
web.config
node_modules
hooks
assets/sass
assets/vendor
1 change: 0 additions & 1 deletion CONTRIBUTING

This file was deleted.

11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ RUN apk update && \
rm -rf /var/www/localhost && \
rm -f /etc/php7/php-fpm.d/www.conf

RUN cd /tmp \
&& curl -sL -o kb.zip https://github.com/kanboard/kanboard/archive/$VERSION.zip \
&& unzip -qq kb.zip \
&& cd kanboard-* \
&& cp -R . /var/www/app \
&& cd /tmp \
&& rm -rf /tmp/kanboard-* /tmp/*.zip

ADD . /var/www/app
ADD docker/ /

RUN rm -rf /var/www/app/docker && echo $VERSION > /version.txt

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD []
35 changes: 28 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,70 @@
DOCKER_IMAGE := kanboard/kanboard
DOCKER_TAG := master
VERSION := $(shell git rev-parse --short HEAD)

.PHONY: all
all: static

.PHONY: clean
clean:
@ rm -rf ./node_modules

.PHONY: static
static: clean
@ npm install
@ ./node_modules/.bin/gulp vendor js css
@ ./node_modules/.bin/jshint assets/js/{core,components,polyfills}

.PHONY: jshint
jshint:
@ ./node_modules/.bin/jshint assets/js/{core,components,polyfills}

.PHONY: archive
archive:
@ echo "Build archive: version=${version}, destination=${dst}"
@ git archive --format=zip --prefix=kanboard/ ${version} -o ${dst}/kanboard-${version}.zip

test-sqlite-coverage:
@ ./vendor/bin/phpunit --coverage-html /tmp/coverage --whitelist app/ -c tests/units.sqlite.xml
@ echo "Build archive: version=$(VERSION)"
@ git archive --format=zip --prefix=kanboard/ $(VERSION) -o kanboard-$(VERSION).zip

.PHONY: test-sqlite
test-sqlite:
@ ./vendor/bin/phpunit -c tests/units.sqlite.xml

.PHONY: test-mysql
test-mysql:
@ ./vendor/bin/phpunit -c tests/units.mysql.xml

.PHONY: test-postgres
test-postgres:
@ ./vendor/bin/phpunit -c tests/units.postgres.xml

.PHONY: test-browser
test-browser:
@ ./vendor/bin/phpunit -c tests/acceptance.xml

.PHONY: integration-test-mysql
integration-test-mysql:
@ composer install --dev
@ docker-compose -f tests/docker/compose.integration.mysql.yaml build
@ docker-compose -f tests/docker/compose.integration.mysql.yaml up -d mysql app
@ docker-compose -f tests/docker/compose.integration.mysql.yaml up tests
@ docker-compose -f tests/docker/compose.integration.mysql.yaml down

.PHONY: integration-test-postgres
integration-test-postgres:
@ composer install --dev
@ docker-compose -f tests/docker/compose.integration.postgres.yaml build
@ docker-compose -f tests/docker/compose.integration.postgres.yaml up -d postgres app
@ docker-compose -f tests/docker/compose.integration.postgres.yaml up tests
@ docker-compose -f tests/docker/compose.integration.postgres.yaml down

.PHONY: integration-test-sqlite
integration-test-sqlite:
@ composer install --dev
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml build
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml up -d app
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml up tests
@ docker-compose -f tests/docker/compose.integration.sqlite.yaml down

.PHONY: sql
sql:
@ pg_dump -x -O --schema-only --no-owner --no-privileges --quote-all-identifiers -n public --file app/Schema/Sql/postgres.sql kanboard
@ pg_dump -d kanboard --column-inserts --data-only --table settings >> app/Schema/Sql/postgres.sql
Expand All @@ -71,7 +85,14 @@ sql:

@ grep -v "SET idle_in_transaction_session_timeout = 0;" app/Schema/Sql/postgres.sql > temp && mv temp app/Schema/Sql/postgres.sql

.PHONY: docker-image
docker-image:
@ IMAGE_NAME=kanboard/kanboard:latest ./hooks/build
@ docker build --build-arg VERSION=$(VERSION) -t $(DOCKER_IMAGE):$(DOCKER_TAG) .

.PHONY: all
.PHONY: docker-run
docker-run:
@ docker run --rm --name=kanboard -p 80:80 -p 443:443 $(DOCKER_IMAGE):$(DOCKER_TAG)

.PHONY: docker-sh
docker-sh:
@ docker exec -ti kanboard bash
8 changes: 0 additions & 8 deletions app.json

This file was deleted.

8 changes: 4 additions & 4 deletions app/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ function array_column_sum(array &$input, $column)
*/
function build_app_version($ref, $commit_hash)
{
$version = 'master';

if ($ref !== '$Format:%d$') {
$tag = preg_replace('/\s*\(.*tag:\sv([^,]+).*\)/i', '\1', $ref);

Expand All @@ -177,10 +175,12 @@ function build_app_version($ref, $commit_hash)
}

if ($commit_hash !== '$Format:%H$') {
$version .= '.'.$commit_hash;
return 'master.'.$commit_hash;
} else if (file_exists('/version.txt')) {
return file_get_contents('/version.txt');
}

return $version;
return 'master.unknown_revision';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion docker/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ http {

server {
listen 80;
listen 443 ssl;
listen 443 ssl http2;
ssl_certificate /etc/nginx/ssl/kanboard.crt;
ssl_certificate_key /etc/nginx/ssl/kanboard.key;
server_name localhost;
Expand Down
2 changes: 1 addition & 1 deletion docker/usr/local/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

#generate a new self signed SSL certificate when none is provided in the volume
# Generate a new self signed SSL certificate when none is provided in the volume
if [ ! -f /etc/nginx/ssl/kanboard.key ] || [ ! -f /etc/nginx/ssl/kanboard.crt ]
then
openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/kanboard.key -out /etc/nginx/ssl/kanboard.crt -subj "/C=GB/ST=London/L=London/O=Self Signed/OU=IT Department/CN=kanboard.org"
Expand Down
15 changes: 0 additions & 15 deletions hooks/build

This file was deleted.

0 comments on commit 6d2b2f4

Please sign in to comment.