-
Notifications
You must be signed in to change notification settings - Fork 50
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
Added fully configured Docker image #83
base: master
Are you sure you want to change the base?
Changes from all commits
5d0a5c0
54a907a
bf7222c
4f30da9
39d64b6
a56dfe8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/.settings | ||
/.project | ||
/.buildpath | ||
/.composer | ||
/.idea | ||
/satis.phar | ||
/vendor | ||
/satis.json | ||
/web/packages.json | ||
/web/include | ||
/web/dist | ||
!/web/robots.txt | ||
/config.yml | ||
/cache/* | ||
/logs/* | ||
/satis/* | ||
/database.sqlite |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/.project | ||
/.buildpath | ||
/.composer | ||
/.idea | ||
/satis.phar | ||
/vendor | ||
/satis.json | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM composer | ||
|
||
FROM webdevops/php-nginx:7.2 | ||
|
||
ENV WEB_DOCUMENT_ROOT=/app/web | ||
ENV COMPOSER_ALLOW_SUPERUSER 1 | ||
|
||
ENV PACKAGES_NAME='Terramar Labs' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep the amount of image layers as small as possible, you should use:
|
||
ENV PACKAGES_HOMEPAGE='https://github.com/terramar-labs/packages' | ||
ENV PACKAGES_CONTACT='[email protected]' | ||
ENV PACKAGES_BASEPATH='https://localhost' | ||
ENV PACKAGES_SECURE=false | ||
ENV PACKAGES_USER=user | ||
ENV PACKAGES_PASSWORD=password | ||
ENV PACKAGES_PDO_DRIVER=pdo_sqlite | ||
ENV PACKAGES_PDO_PATH=%app.root_dir%/database.sqlite | ||
ENV PACKAGES_PDO_DBNAME=packages | ||
ENV PACKAGES_REDIS_HOST='redis://redis' | ||
ENV PACKAGES_REDIS_PORT=6379 | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=0 /usr/bin/composer /usr/bin/composer | ||
|
||
RUN apt-get update \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The webdevops image contains a helpful wrapper |
||
&& apt-get install -y gettext-base procps \ | ||
&& rm -r /var/lib/apt/lists/* | ||
|
||
COPY . /app | ||
COPY ./docker/nginx/vhost.common.d/vhost.common.conf /opt/docker/etc/nginx/vhost.common.d/10-location-root.conf | ||
RUN chown -R 1000:1000 /app | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reduce number of image layers also here by executing concatenated RUN commands |
||
RUN composer install | ||
|
||
RUN mkdir /root/.ssh \ | ||
&& ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts \ | ||
&& ssh-keyscan -t rsa bitbucket.org >> /root/.ssh/known_hosts \ | ||
&& ssh-keyscan -t rsa gitlab.com >> /root/.ssh/known_hosts | ||
|
||
ENTRYPOINT envsubst < config.yml.tmpl > config.yml \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should add a supervisord service for the resque worker and there's also a mechanism for doing startup commands in the docker container: |
||
&& bin/console resque:worker:start \ | ||
&& /entrypoint supervisord | ||
CMD [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,9 +102,66 @@ Some tips: | |
Docker support | ||
-------------- | ||
|
||
Packages comes with an example `docker-compose.yml` that starts an nginx container and a Redis container, ready to get up and running quickly. | ||
You can find a fully configured instance of Packages on [Docker Hub](https://hub.docker.com/r/mkerix/packages/). | ||
|
||
### Installation | ||
|
||
After booting up the container you still need to create the database schema by running in the container `bin/console orm:schema-tool:create`. | ||
This container does not apply migrations automatically, you'll have to run the migrations manually in the same fashion when updating the version. | ||
|
||
The docker-compose file in this repository is great for local development use, but in production you should consider the following setup: | ||
|
||
```yml | ||
version: '2' | ||
services: | ||
packages: | ||
image: mkerix/packages | ||
environment: | ||
PACKAGES_NAME: Name | ||
PACKAGES_HOMEPAGE: Homepage | ||
PACKAGES_CONTACT: [email protected] | ||
PACKAGES_BASEPATH: https://satis.example.com | ||
PACKAGES_USER: user | ||
PACKAGES_PASSWORD: password | ||
PACKAGES_PDO_PATH: '%app.root_dir%/database/database.sqlite' | ||
volumes: | ||
- /host/packages/database:/app/database | ||
- /host/packages/satis:/app/satis | ||
- /host/packages/ssh:/home/application/.ssh | ||
redis: | ||
image: redis | ||
``` | ||
|
||
Adjust the environment variables as well as the volume links on the host to your liking and then generate a new SSH key and known_hosts file in the ssh folder. | ||
The generated public key needs to be added to a user with access to your composer repositories. | ||
This is needed so that Satis can pull the repositories successfully. | ||
|
||
### Configuration | ||
|
||
The following environment variables can optionally be used to configure your instance. | ||
|
||
#### Customization | ||
- `PACKAGES_NAME` - instance name | ||
- `PACKAGES_HOMEPAGE` - instance homepage link | ||
- `PACKAGES_CONTACT` - contact mail | ||
- `PACKAGES_BASEPATH` - full base URL to the instance | ||
|
||
Visit [the documentation](http://docs.terramarlabs.com/packages/3.2/getting-started/docker) to get started. | ||
#### Security | ||
- `PACKAGES_SECURE` - whether Satis should be secured too or not | ||
- `PACKAGES_USER` - username | ||
- `PACKAGES_PASSWORD` - password | ||
|
||
#### Database | ||
- `PACKAGES_PDO_DRIVER` - pdo driver | ||
- `PACKAGES_PDO_PATH` - path to the database file, e.g. for sqlite | ||
- `PACKAGES_PDO_HOST` - database host | ||
- `PACKAGES_PDO_USER` - database user | ||
- `PACKAGES_PDO_PASSWORD` - database password | ||
- `PACKAGES_PDO_DBNAME` - database name | ||
- `PACKAGES_REDIS_HOST` - Redis host | ||
- `PACKAGES_REDIS_PORT` - Redis port | ||
|
||
Visit [the documentation](http://docs.terramarlabs.com/packages/3.2/getting-started/docker) to learn more. | ||
|
||
Troubleshooting | ||
--------------- | ||
|
@@ -131,4 +188,8 @@ Troubleshooting | |
```bash | ||
tail -f logs/resque.log | ||
``` | ||
4. If running in Docker make sure that all files belong to the application user. Change the ownership from within the container: | ||
```bash | ||
chown -R application:application /app | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
security: | ||
# Username and password to access the web management interface | ||
username: '$PACKAGES_USER' | ||
password: '$PACKAGES_PASSWORD' | ||
|
||
doctrine: | ||
mapping: | ||
default: | ||
paths: [ '%app.root_dir%/src/Entity', '%app.root_dir%/src/Plugin' ] | ||
namespace: Terramar | ||
|
||
database: | ||
# Any Doctrine driver | ||
driver: $PACKAGES_PDO_DRIVER | ||
|
||
# Options | ||
path: '$PACKAGES_PDO_PATH' | ||
host: '$PACKAGES_PDO_HOST' | ||
user: '$PACKAGES_PDO_USER' | ||
password: '$PACKAGES_PDO_PASSWORD' | ||
dbname: '$PACKAGES_PDO_DBNAME' | ||
|
||
packages: | ||
# Defines the name used in the page titles and landing page. | ||
name: '$PACKAGES_NAME' | ||
|
||
# If set, the homepage will be linked to from the landing page. | ||
homepage: '$PACKAGES_HOMEPAGE' | ||
|
||
# If set, the contact email is displayed on the landing page. | ||
contact_email: '$PACKAGES_CONTACT' | ||
|
||
# Needs to be set to generate a dist archive | ||
base_path: '$PACKAGES_BASEPATH' | ||
|
||
# If set, will place a copy of every tagged package version in the web/dist folder | ||
archive: true | ||
|
||
# If set, username and password will be required when attempting to access | ||
# Satis-generated files. | ||
secure_satis: $PACKAGES_SECURE | ||
|
||
resque: | ||
# Redis server host. | ||
host: '$PACKAGES_REDIS_HOST' | ||
# Format as either unix:///path/to/socket (note the 3 slashes) or redis://host | ||
#host: 'unix:///var/run/redis.sock' | ||
# If Redis is configured to require a password, you can pass it in the host: | ||
#host: 'redis://ignored:password@host' | ||
# Note that the username portion of the hostname is ignored and can be any value. | ||
|
||
# Redis TCP port. If using a unix socket, this is ignored. | ||
port: $PACKAGES_REDIS_PORT | ||
|
||
# Redis database index where jobs will be stored. | ||
database: 4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
version: '2' | ||
services: | ||
web: | ||
image: webdevops/php-nginx:7.1 | ||
build: . | ||
volumes: | ||
- .:/app | ||
- ./docker/nginx/vhost.common.d/vhost.common.conf:/opt/docker/etc/nginx/vhost.common.d/10-location-root.conf | ||
links: | ||
- redis | ||
environment: | ||
- WEB_DOCUMENT_ROOT=/app/web | ||
ports: | ||
- "127.0.0.1:80:80" # Access Packages in your browser at http://127.0.0.1:80 | ||
- "127.0.0.1:443:443" # Access Packages in your browser at https://127.0.0.1:443 | ||
- 8080:80 | ||
redis: | ||
image: redis:3.2 | ||
expose: | ||
- "6379" | ||
image: redis |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
location / { | ||
try_files $uri $uri/ /index_dev.php$is_args$args; | ||
try_files $uri $uri/ /index.php$is_args$args; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Composer is already included in
webdevops/php-nginx:7.2
and updated on every image build.