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

Attempt to launch as a regular user #178

Merged
merged 11 commits into from
Mar 21, 2017
Merged
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
35 changes: 21 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV cachet_ver ${cachet_ver:-master}

ENV PG_MAJOR 9.5
ENV NGINX_VERSION 1.10.1-1~jessie
ENV COMPOSER_VERSION 1.2.1
ENV COMPOSER_VERSION 1.4.1

RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
Expand Down Expand Up @@ -35,6 +35,13 @@ RUN DEBIAN_FRONTEND=noninteractive \
apt-get clean && apt-get autoremove -q && \
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/*

# Install composer
RUN php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" && \
php -r "copy('https://composer.github.io/installer.sig', '/tmp/composer-setup.sig');" && \
php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && \
php /tmp/composer-setup.php --version=$COMPOSER_VERSION --install-dir=bin && \
php -r "unlink('/tmp/composer-setup.php');"

COPY conf/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf
COPY conf/supervisord.conf /etc/supervisor/supervisord.conf
COPY conf/nginx-site.conf /etc/nginx/conf.d/default.conf
Expand All @@ -43,34 +50,34 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN mkdir -p /var/www/html && \
chown -R www-data /var/www

RUN adduser www-data sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log

RUN touch /var/run/nginx.pid && \
chown -R www-data:www-data /var/run/nginx.pid && \
chown -R www-data:www-data /var/cache/nginx

RUN touch /var/run/php5-fpm.pid && \
chown -R www-data:www-data /var/run/php5-fpm.pid

RUN adduser www-data sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

WORKDIR /var/www/html/
USER www-data

# Install composer
RUN php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" && \
php -r "copy('https://composer.github.io/installer.sig', '/tmp/composer-setup.sig');" && \
php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && \
php /tmp/composer-setup.php --version=$COMPOSER_VERSION && \
php -r "unlink('/tmp/composer-setup.php');" && \
php composer.phar global require "hirak/prestissimo:^0.3"

RUN wget https://github.com/cachethq/Cachet/archive/${cachet_ver}.tar.gz && \
tar xzvf ${cachet_ver}.tar.gz --strip-components=1 && \
chown -R www-data /var/www/html && \
rm -r ${cachet_ver}.tar.gz && \
php composer.phar install --no-dev -o && \
php /bin/composer.phar global require "hirak/prestissimo:^0.3" && \
php /bin/composer.phar install --no-dev -o && \
rm -rf bootstrap/cache/*

COPY conf/.env.docker /var/www/html/.env
COPY entrypoint.sh /sbin/entrypoint.sh

EXPOSE 80
EXPOSE 8000

CMD ["/sbin/entrypoint.sh"]
2 changes: 1 addition & 1 deletion conf/nginx-site.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80 default; ## Listen for ipv4; this line is default and implied
listen 8000 default; ## Listen for ipv4; this line is default and implied

# Make site accessible from http://localhost/
server_name localhost;
Expand Down
4 changes: 1 addition & 3 deletions conf/php-fpm-pool.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[www]
user = www-data
group = www-data

listen = 9000

request_terminate_timeout = 120s
Expand All @@ -25,3 +22,4 @@ access.log = /dev/stdout
[global]
daemonize = no
error_log = /dev/stderr
pid = /var/run/php5-fpm.pid
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
cachet:
build: .
ports:
- 80:80
- 80:8000
links:
- postgres:postgres
environment:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ start_system() {
check_configured
echo "Starting Cachet! ..."
php artisan config:cache
sudo /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
}

start_system
Expand Down
2 changes: 1 addition & 1 deletion openshift/cachethd-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ spec:
dnsPolicy: ClusterFirst
securityContext:
runAsUser: 0
status:
status:
2 changes: 1 addition & 1 deletion test/docker-compose-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
cachet:
image: docker_cachet
ports:
- 80:80
- 80:8000
links:
- mysql:mysql
environment:
Expand Down
10 changes: 5 additions & 5 deletions test/test.full.bats
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ load "lib/output"
}

@test "[$TEST_FILE] curl 200 response test" {
run curl_container docker_cachet_1 /auth/login --head
run curl_container docker_cachet_1 :8000/auth/login --head
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}

@test "[$TEST_FILE] login test" {
run curl_container docker_cachet_1 /auth/login --head --user test:test123
run curl_container docker_cachet_1 :8000/auth/login --head --user test:test123
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}

@test "[$TEST_FILE] check for curl API pong" {
run curl_container docker_cachet_1 /api/v1/ping
run curl_container docker_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}

Expand All @@ -86,12 +86,12 @@ load "lib/output"
}

@test "[$TEST_FILE] post-restart API pong" {
run curl_container docker_cachet_1 /api/v1/ping
run curl_container docker_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}

@test "[$TEST_FILE] post-restart login test" {
run curl_container docker_cachet_1 /auth/login --head --user test:test123
run curl_container docker_cachet_1 :8000/auth/login --head --user test:test123
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}

Expand Down
10 changes: 5 additions & 5 deletions test/test.mysql.bats
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ load "lib/output"
}

@test "[$TEST_FILE] curl 200 response test" {
run curl_container test_cachet_1 /auth/login --head
run curl_container test_cachet_1 :8000/auth/login --head
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}

@test "[$TEST_FILE] login test" {
run curl_container test_cachet_1 /auth/login --head --user test:test123
run curl_container test_cachet_1 :8000/auth/login --head --user test:test123
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}

@test "[$TEST_FILE] check for curl API pong" {
run curl_container test_cachet_1 /api/v1/ping
run curl_container test_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}

Expand All @@ -68,12 +68,12 @@ load "lib/output"
}

@test "[$TEST_FILE] post-restart API pong" {
run curl_container test_cachet_1 /api/v1/ping
run curl_container test_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}

@test "[$TEST_FILE] post-restart login test" {
run curl_container test_cachet_1 /auth/login --head --user test:test123
run curl_container test_cachet_1 :8000/auth/login --head --user test:test123
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}

Expand Down