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

Update Circle CI config #39

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
59 changes: 59 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
version: 2

jobs:
build:
docker:
- image: circleci/php:7.2-cli-stretch-node
steps:
- run: sudo composer self-update
- checkout
- run: cp ~/project/config/parameters.yml.dist ~/project/config/parameters.yml

- restore_cache:
keys:
- project-dependencies-{{ checksum "~/project/composer.lock" }}
- composer-cache

- run: composer install -n -o

- save_cache:
key: project-dependencies-{{ checksum "~/project/composer.lock" }}
paths:
- ~/project/vendor
- save_cache:
key: composer-cache
paths:
- ~/.composer/cache

- run: make test
- store_test_results:
path: build
- store_artifacts:
path: build

deploy:
docker:
- image: circleci/php:7.2-cli-stretch-node
steps:
- checkout
- run: npm install
- run: node_modules/.bin/encore prod
- restore_cache:
keys:
- project-dependencies-{{ checksum "~/project/composer.lock" }}
- composer-cache
- run: composer install -n -o
- run: cp ~/.ssh/id_amsterdamphp.nl ~/.ssh/id_rsa
- run: ./vendor/bin/dep deploy

workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
filters:
branches:
only: master
requires:
- build
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NGINX_DOCUMENT_ROOT=/opt/project/web
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
/build/
/vendor/
/cache/*
/logs/*
silex.log
/config/parameters.yml
/.vagrant
node_modules/
web/css/*
web/img/*
web/js/*

/.phpunit.result.cache
/var/
!/var/.gitkeep
cache/*
logs/*
###> symfony/webpack-encore-bundle ###
/node_modules/
/web/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "ansible"]
path = ansible
url = [email protected]:heybigname/ansible.git
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
ENV?=dev
SHELL=bash

# set all to phony
.PHONY: *

help: ## Show help
@echo
@echo "Usage: make [target]"
@echo
@printf "\033[1;93mAvailable targets:\033[0m\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo


mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(abspath $(patsubst %/,%,$(dir $(mkfile_path))))

PROJECT_NAME=amsterdamphp-raffler
IMAGE_TAG=usabillabv/php

DOCKER_RUN=docker run --rm -t \
-v "${current_dir}:/opt/project" -v "${HOME}/.config/composer:/.config/composer" \
-e COMPOSER_HOME=/.config/composer \
--workdir=/opt/project \
"${IMAGE_TAG}:${PROJECT_NAME}-dev"

all: install check up ## Runs everything

install: docker-build node_modules build-assets

check: docker-lint

test: unit-tests

export DOCKER_BUILDKIT=1
docker-build:
docker build -t "${IMAGE_TAG}:${PROJECT_NAME}-dev" --target=dev -f docker/Dockerfile-fpm .

docker-check: # If the docker image isn't built, do it
ifeq ($(shell docker images --filter=reference="${IMAGE_TAG}:${PROJECT_NAME}-dev" --format={{.ID}}),)
$(MAKE) docker-build
endif

docker-lint: # Lints Dockerfile with Hadolint
docker run --rm -t -v $(current_dir):/p --workdir=/p hadolint/hadolint:latest-debian hadolint ./docker/Dockerfile-fpm

PORT?=8081
up: docker-check # Runs Nginx and FPM containers while sharing the socket among them
@docker-compose up -d
@docker run --name "${PROJECT_NAME}-fpm" --rm -d -m 256M --network amsphpraffler --env-file=./.env -v $(current_dir):/opt/project:rw "${IMAGE_TAG}:${PROJECT_NAME}-dev"
@docker run --name "${PROJECT_NAME}-nginx" --rm -d -m 64M --network amsphpraffler --env-file=./.env -p ${PORT}:80 --volumes-from="${PROJECT_NAME}-fpm" "${IMAGE_TAG}:nginx" || ($(MAKE) down && exit 1)
@echo -e "\033[0;32m [RUNNING] \033[0m \033[0;33m http://localhost:${PORT}/\033[0m"

down: # Stop the containers
@docker stop -t 2 "${PROJECT_NAME}-nginx" || true
@docker stop -t 5 "${PROJECT_NAME}-fpm" || true
@docker-compose down
@echo -e "\033[0;32m [STOPPED] \033[0m\033[0m" $<

install-composer: docker-check ## Install dependencies with composer
$(DOCKER_RUN) composer install --prefer-dist -n -o $(FLAGS)


build-assets: ## Build JS, CSS and images
node_modules/.bin/encore $(ENV)

node_modules: package.json
npm install

unit-tests: ## Run unit tests
vendor/bin/phpunit
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AmsterdamPHP - Meetup.com Raffler

This application enables us to raffle off stuff to our meetup attendees. It uses the Meetup.com API to get all check ins, and then uses the Random.org API to randomly select winners.
This application enables us to raffle off stuff to our meetup attendees. It uses the Meetup.com API to get all check ins, and then randomly selects winners.

## Installation

Expand All @@ -9,50 +9,49 @@ This application enables us to raffle off stuff to our meetup attendees. It uses
Ensure that [VirtualBox](https://www.virtualbox.org), [Vagrant](http://www.vagrantup.com), and [Ansible](http://www.ansible.com) are installed.

1. `git clone [email protected]:AmsterdamPHP/meetup-raffle-machine.git --recursive`
2. run `vagrant up`
3. create config/parameters.yml (get your API key from [meetup.com](https://secure.meetup.com/meetup_api/key/))
1. run `vagrant up`
1. create `config/parameters.yml` (get your API key from [meetup.com](https://secure.meetup.com/meetup_api/key/))

```
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
parameters:
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
secret: SomeRandomSecretToSeedSymfony
redis_dsn: redis://localhost
```
1. Add the following to your hosts file: `10.10.10.10 raffler.local`

All done! Now you can access the application at [http://app.local/](http://app.local/).
All done! Now you can access the application at [http://raffler.local/](http://raffler.local/).

### Install directly onto your host machine.

1. Get code
2. Give permissions
1. Give permissions

```
sudo chmod -Rf +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" cache logs
sudo chmod -Rf +a "<apache user> allow delete,write,append,file_inherit,directory_inherit" cache logs
```

3. Install Dependencies
1. Install Dependencies

```
composer install
npm install
make install
```

4. Compile assets

```
./node_modules/.bin/gulp
```

5. Create config/parameters.yml
1. Create config/parameters.yml

```
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
parameters:
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
secret: SomeRandomSecretToSeedSymfony
redis_dsn: redis://localhost
```

## How to use it

1. Open the app index page to be presented with a list of meetups.
2. Click on a meetup.
3. Press [space] or [page down] to start raffles.
1. Click on a meetup.
1. Press [space] or [page down] to start raffles.

The page down key allows us to use most presentation remotes as well.
63 changes: 0 additions & 63 deletions Vagrantfile

This file was deleted.

1 change: 0 additions & 1 deletion ansible
Submodule ansible deleted from 536a41
3 changes: 3 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: lightgray;
}
14 changes: 14 additions & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/

// any CSS you require will output into a single css file (app.css in this case)
require('../css/app.css');

// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
// const $ = require('jquery');

console.log('Hello Webpack Encore! Edit me in assets/js/app.js');
42 changes: 42 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env php
<?php

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
}

set_time_limit(0);

require dirname(__DIR__).'/vendor/autoload.php';

if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
Empty file removed cache/.gitkeep
Empty file.
24 changes: 0 additions & 24 deletions circle.yml

This file was deleted.

Loading