-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from envato/docker
Docker development environment
- Loading branch information
Showing
7 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*.gem | ||
*.rbc | ||
/.* | ||
!/.rspec | ||
/coverage/ | ||
/Dockerfile | ||
/docker-compose*.yml | ||
/pkg/ | ||
/tmp/ | ||
/profiles/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
/Gemfile.lock | ||
/log/ | ||
/spec/examples.txt | ||
/spec/reports/ | ||
/spec/support/database.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM ruby:2.5-alpine | ||
|
||
WORKDIR /double_entry | ||
|
||
RUN set -ex; \ | ||
apk add --no-cache \ | ||
build-base \ | ||
git \ | ||
mariadb-dev \ | ||
postgresql-dev \ | ||
sqlite-dev \ | ||
tzdata \ | ||
; \ | ||
gem update --system | ||
|
||
COPY Gemfile* double_entry.gemspec ./ | ||
COPY lib/double_entry/version.rb ./lib/double_entry/version.rb | ||
RUN bundle install | ||
|
||
COPY . ./ | ||
COPY spec/support/database.example.yml ./spec/support/database.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,42 +292,56 @@ See the Github project [issues](https://github.com/envato/double_entry/issues). | |
|
||
## Development Environment Setup | ||
|
||
1. Clone this repo. | ||
We're using Docker to provide a convenient and consistent environment for | ||
executing tests during development. This allows engineers to quickly set up | ||
a productive development environment. | ||
|
||
```sh | ||
git clone [email protected]:envato/double_entry.git && cd double_entry | ||
``` | ||
Note: Most development files are mounted in the Docker container. This | ||
enables engineers to edit files in their favourite editor (on the host | ||
OS) and have the changes immediately available in the Docker container | ||
to be exercised. | ||
|
||
One exception to this is the RSpec configuration. Changes to these files will | ||
require a rebuild of the Docker image (step 2). | ||
|
||
2. Run the included setup script to install the gem dependencies. | ||
Prerequisites: | ||
|
||
* Docker | ||
* Docker Compose | ||
* Git | ||
|
||
1. Clone this repo. | ||
|
||
```sh | ||
./script/setup.sh | ||
git clone [email protected]:envato/double_entry.git && cd double_entry | ||
``` | ||
|
||
3. Install MySQL, PostgreSQL and SQLite. We run tests against all three databases. | ||
4. Create a database in MySQL. | ||
2. Build the Docker image we'll use to run tests | ||
```sh | ||
mysql -u root -e 'create database double_entry_test;' | ||
docker-compose build --pull double_entry | ||
``` | ||
5. Create a database in PostgreSQL. | ||
3. Startup a container and attach a terminal. This will also start up a | ||
MySQL and Postgres database. | ||
```sh | ||
psql -c 'create database double_entry_test;' -U postgres | ||
docker-compose run --rm double_entry ash | ||
``` | ||
6. Specify how the tests should connect to the database | ||
4. Run the tests | ||
```sh | ||
cp spec/support/{database.example.yml,database.yml} | ||
vim spec/support/database.yml | ||
DB=mysql bundle exec rspec | ||
DB=postgres bundle exec rspec | ||
DB=sqlite bundle exec rspec | ||
``` | ||
7. Run the tests | ||
5. When finished, exit the container terminal and shut down the databases. | ||
```sh | ||
bundle exec rake | ||
exit | ||
docker-compose down | ||
``` | ||
## Contributors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '3' | ||
services: | ||
double_entry: | ||
build: . | ||
environment: | ||
POSTGRES_HOST: postgres | ||
MYSQL_HOST: mysql | ||
volumes: | ||
- ./lib:/double_entry/lib | ||
- ./spec/double_entry:/double_entry/spec/double_entry | ||
- ./spec/double_entry_spec.rb:/double_entry/spec/double_entry_spec.rb | ||
- ./spec/generators:/double_entry/spec/generators | ||
- ./spec/active_record:/double_entry/spec/active_record | ||
- ./spec/performance:/double_entry/spec/performance | ||
- ./script:/double_entry/script | ||
depends_on: | ||
- mysql | ||
- postgres | ||
mysql: | ||
image: mysql | ||
environment: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: 'true' | ||
MYSQL_DATABASE: double_entry_test | ||
postgres: | ||
image: postgres:alpine | ||
environment: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
POSTGRES_DB: double_entry_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters