How do I mount a host volume into docker with the ruby docker-api (https://github.com/swipely/docker-api) on runtime?
Basically, the docker run -v path:path functionality with this gem.
The current README missed the part to explain on how to use the volumes with container. You should be fine to run with below command with container's folder /foo
container = Docker::Container.create('Cmd' => %w[test -d /foo],
'Image' => 'debian:wheezy',
'Volumes' => {'/foo' => {}}
)
If you need mount with local folder, update to Volumes' => {'/foo' => '/local_foo'}
You can refer the test case from:
container_spec.rb
Documentation for docker-api gem states this in its README.md:
require 'docker'
# Create a Container.
container = Docker::Container.create('Cmd' => ['ls'], 'Image' => 'base')
# Attach to the Container. Currently, the below options are the only valid ones.
# By default, :stream, :stdout, and :stderr are set.
container.attach(:stream => true, :stdin => nil, :stdout => true, :stderr => true, :logs => true, :tty => false)
# => [["bin\nboot\ndev\netc\nhome\nlib\nlib64\nmedia\nmnt\nopt\nproc\nroot\nrun\nsbin\nselinux\nsrv\nsys\ntmp\nusr\nvar", []]
# If you wish to stream the attach method, a block may be supplied.
container = Docker::Container.create('Image' => 'base', 'Cmd' => ['find / -name *'])
container.tap(&:start).attach { |stream, chunk| puts "#{stream}: #{chunk}" }
stderr: 2013/10/30 17:16:24 Unable to locate find / -name *
# => [[], ["2013/10/30 17:16:24 Unable to locate find / -name *\n"]]
# If you want to attach to stdin of the container, supply an IO-like object:
container = Docker::Container.create('Image' => 'base', 'Cmd' => ['cat'], 'OpenStdin' => true, 'StdinOnce' => true)
container.tap(&:start).attach(stdin: StringIO.new("foo\nbar\n"))
# => [["foo\nbar\n"], []]
Does this help? Can I ask why are you trying to use docker-api? Can't you just use docker volumes (-v)?
Use Binds:
'Binds' => ['/local/folder:/container/folder']
You need to use both Marcelo's and BMW's answers together to create a container with a working volume:
container = Docker::Container.create('Cmd' => %w[test -d /foo],
'Image' => 'debian:wheezy',
'Volumes' => '/container' => {},
'Binds' => ['/local:/container']
)
Related
I am using PHPUnit through PhpStorm with a remote interpreter from docker.
The Container is run through docker-compose
PHPUnit works. Xdebug works through the browser. In docker-php-ext-xdebug.ini, I have all the mandatory options, and I can see in the CLI Interpreter Config that PhpStorm does load this config.
BUT when I try to run PHPUnit with the debugger I get:
PhpStorm Debugger extension is not detected
CLI Interpreter Config:
DockerFile
FROM php:7.4-fpm-alpine
# OS DEPENDENCIES
RUN apk update
RUN apk add --no-cache bash git curl libmcrypt libmcrypt-dev openssh-client icu-dev
RUN apk add --no-cache libxml2-dev freetype-dev libpng-dev libjpeg-turbo-dev zip libzip-dev g++ make autoconf
RUN apk add --no-cache postgresql-dev
RUN docker-php-source extract
RUN pecl install xdebug redis
RUN docker-php-ext-enable xdebug redis
RUN docker-php-source delete
RUN docker-php-ext-install -j$(nproc) pgsql
RUN docker-php-ext-install -j$(nproc) pdo_pgsql
RUN docker-php-ext-install soap intl zip
RUN docker-php-ext-install opcache
# XDEBUG CONFIGURATION
ARG XDEBUG_REMOTE_HOST
ARG XDEBUG_REMOTE_PORT
ARG XDEBUG_REMOTE_CONNECT_BACK
ARG XDEBUG_INI=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "error_reporting = E_ALL" >> ${XDEBUG_INI}
RUN echo "display_startup_errors=1" >> ${XDEBUG_INI}
RUN echo "display_errors=1" >> ${XDEBUG_INI}
RUN echo "xdebug.profiler_enable=1" >> ${XDEBUG_INI}
RUN echo "xdebug.remote_enable=1" >> ${XDEBUG_INI}
RUN echo "xdebug.remote_connect_back=$XDEBUG_REMOTE_CONNECT_BACK" >> ${XDEBUG_INI}
RUN echo "xdebug.idekey=\"PHPSTORM\"" >> ${XDEBUG_INI}
RUN echo "xdebug.remote_handler=dbgp" >> ${XDEBUG_INI}
RUN echo "xdebug.remote_port=$XDEBUG_REMOTE_PORT" >> ${XDEBUG_INI}
RUN echo "xdebug.remote_host=$XDEBUG_REMOTE_HOST" >> ${XDEBUG_INI}
RUN echo "xdebug.remote_autostart=1" >> ${XDEBUG_INI}
# COMPOSER INSTALLATION
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# EXORT COMPOSER GLOBAL PATH
ENV PATH="$PATH:$HOME/.composer/vendor/bin" #edited
docker-compose.yaml
dataapi:
container_name: dataapi
build:
context: ${DOCKER_FILES_PATH}/privateapi/
args:
- XDEBUG_REMOTE_PORT=10000
- XDEBUG_REMOTE_HOST=172.17.0.1 #DOCKER network IP
- XDEBUG_REMOTE_CONNECT_BACK=0 #edited
command: sh -c "composer install && bin/console doctrine:migrations:migrate --allow-no-migration -n && php-fpm"
UPDATE:
Here is the result of phpinto() in phpunit:
sodium
sodium support => enabled
libsodium headers version => 1.0.18
libsodium library version => 1.0.18
SPL
SPL support => enabled
Interfaces => OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException
sqlite3
SQLite3 support => enabled
SQLite Library => 3.32.1
Directive => Local Value => Master Value
sqlite3.defensive => 1 => 1
sqlite3.extension_dir => no value => no value
standard
Dynamic Library Support => enabled
Path to sendmail => /usr/sbin/sendmail -t -i
Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.exception => 0 => 0
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
from => no value => no value
session.trans_sid_hosts => no value => no value
session.trans_sid_tags => a=href,area=href,frame=src,form= => a=href,area=href,frame=src,form=
unserialize_max_depth => 4096 => 4096
url_rewriter.hosts => no value => no value
url_rewriter.tags => form= => form=
user_agent => no value => no value
tokenizer
Tokenizer Support => enabled
xdebug
xdebug support => enabled
Version => 2.9.6
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
Debugger => enabled
IDE Key => PHPSTORM
Directive => Local Value => Master Value
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.gc_stats_enable => Off => Off
xdebug.gc_stats_output_dir => /tmp => /tmp
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => PHPSTORM => PHPSTORM
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => 2 => 2
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => On => On
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_output_dir => /tmp => /tmp
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_host => 172.17.0.1 => 172.17.0.1
xdebug.remote_log => no value => no value
xdebug.remote_log_level => 7 => 7
xdebug.remote_mode => req => req
xdebug.remote_port => 10000 => 10000
xdebug.remote_timeout => 200 => 200
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /tmp => /tmp
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3
xml
XML Support => active
XML Namespace Support => active
libxml2 Version => 2.9.10
xmlreader
XMLReader => enabled
xmlwriter
XMLWriter => enabled
Zend OPcache
Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI
Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => On => On
opcache.file_cache_only => Off => Off
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0 => 0x7FFEBFFF
opcache.preferred_memory_model => no value => no value
opcache.preload => no value => no value
opcache.preload_user => no value => no value
opcache.protect_memory => Off => Off
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => On => On
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On
zip
Zip => enabled
Zip version => 1.15.6
Libzip headers version => 1.6.1
Libzip library version => 1.6.1
zlib
ZLib Support => enabled
Stream Wrapper => compress.zlib://
Stream Filter => zlib.inflate, zlib.deflate
Compiled Version => 1.2.11
Linked Version => 1.2.11
Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value
Additional Modules
Module Name
Environment
Variable => Value
PATH => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/.composer/vendor/bin
HOSTNAME => fb6d372627df
JETBRAINS_REMOTE_RUN => 1
IDE_PHPUNIT_PHPUNIT_PHAR => /var/www/privateapi/vendor/bin/.phpunit/phpunit-7.5-0/phpunit
IDE_PHPUNIT_VERSION => 7.5.20
PHPIZE_DEPS => autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c
PHP_INI_DIR => /usr/local/etc/php
PHP_EXTRA_CONFIGURE_ARGS => --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
PHP_CFLAGS => -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
PHP_CPPFLAGS => -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
PHP_LDFLAGS => -Wl,-O1 -pie
GPG_KEYS => 42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312
PHP_VERSION => 7.4.7
PHP_URL => https://www.php.net/distributions/php-7.4.7.tar.xz
PHP_ASC_URL => https://www.php.net/distributions/php-7.4.7.tar.xz.asc
PHP_SHA256 => 53558f8f24cd8ab6fa0ea252ca8198e2650160649681ce5230c1df1dc2b52faf
PHP_MD5 =>
HOME => /root
APP_ENV => test
KERNEL_CLASS => App\Kernel
APP_AUTH_API_HOST => http://authapi
DATABASE_URL_TEST => postgresql://postgres:postgres#172.17.0.1:5433/privateapi_test
CORS_ALLOW_ORIGIN => ^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
PHP Variables
Variable => Value
$_ENV['PATH'] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/.composer/vendor/bin
$_ENV['HOSTNAME'] => fb6d372627df
$_ENV['JETBRAINS_REMOTE_RUN'] => 1
$_ENV['IDE_PHPUNIT_PHPUNIT_PHAR'] => /var/www/privateapi/vendor/bin/.phpunit/phpunit-7.5-0/phpunit
$_ENV['IDE_PHPUNIT_VERSION'] => 7.5.20
$_ENV['PHPIZE_DEPS'] => autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c
$_ENV['PHP_INI_DIR'] => /usr/local/etc/php
$_ENV['PHP_EXTRA_CONFIGURE_ARGS'] => --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
$_ENV['PHP_CFLAGS'] => -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
$_ENV['PHP_CPPFLAGS'] => -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
$_ENV['PHP_LDFLAGS'] => -Wl,-O1 -pie
$_ENV['GPG_KEYS'] => 42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312
$_ENV['PHP_VERSION'] => 7.4.7
$_ENV['PHP_URL'] => https://www.php.net/distributions/php-7.4.7.tar.xz
$_ENV['PHP_ASC_URL'] => https://www.php.net/distributions/php-7.4.7.tar.xz.asc
$_ENV['PHP_SHA256'] => 53558f8f24cd8ab6fa0ea252ca8198e2650160649681ce5230c1df1dc2b52faf
$_ENV['PHP_MD5'] =>
$_ENV['HOME'] => /root
$_ENV['APP_ENV'] => test
$_ENV['KERNEL_CLASS'] => App\Kernel
$_ENV['APP_AUTH_API_HOST'] => http://authapi
$_ENV['DATABASE_URL_TEST'] => postgresql://postgres:postgres#172.17.0.1:5433/privateapi_test
$_ENV['CORS_ALLOW_ORIGIN'] => ^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
$_ENV['APP_SECRET'] => $ecretf0rt3st
$_ENV['DATABASE_URL'] =>
$_ENV['SYMFONY_DOTENV_VARS'] => APP_SECRET,DATABASE_URL,SYMFONY_DEPRECATIONS_HELPER,PANTHER_APP_ENV
$_ENV['SYMFONY_DEPRECATIONS_HELPER'] => 999999
$_ENV['PANTHER_APP_ENV'] => panther
$_ENV['APP_DEBUG'] => 1
Set Up:
Ubuntu 20.04
PhpStorm 2020.1.4
Docker 19.03.12
docker-compose 1.26.0
Your Xdebug settings look fine to me. It shows expected values for PHPUnit and it works for a web page debug.
This has to be the IDE settings / some IDE misconfiguration. In particular, make sure that you have selected the default PHP Interpreter. Even though you have specified one in your Run/Debug Configuration, PhpStorm still requires a project-default interpreter to be selected -- it's a know limitation: WI-51570.
Settings/Preferences | Languages & Frameworks | PHP | CLI Interpreter
NOTE: as of 2021.1 version the PHP settings node has been moved to the top level and now it's Settings/Preferences | PHP | CLI Interpreter
P.S. You can also set it via File | New Projects Settings | Settings for New Projects.... This way it will be set for all future new projects created on that computer (which you can then change as required on per project basis).
I had this problem.
I fixed it by specifying the CLI Interpreter in Preferences > PHP
This will not work in your docker since the steps will be removed when running the container:
RUN echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
RUN source ~/.bashrc
you may use:
ENV PATH="$PATH:$HOME/.composer/vendor/bin"
Update
You may also not using the IP in your config, instead you can map the port to your host when starting your container.
First change XDEBUG_REMOTE_HOST=172.17.0.1 to XDEBUG_REMOTE_HOST=0.0.0.0
I had this same issue. However it turned out in XDebug 3 the port changed to 9003.
Ctrl + Alt + S > Languages & Frameworks > PHP > Debug > Debug Port to 9003
I'm attempting to compare my data, which is in the format of an array of hashes, with another large array of hashes (~50K server names and tags) which serves as a dictionary. The dictionary is stripped down to only include the absolutely relevant information.
The code I have works but it is quite slow on this scale and I haven't been able to pinpoint why. I've done verbose printing to isolate the issue to a specific statement (tagged via comments below)--when it is commented out, the code runs ~30x faster.
After reviewing the code extensively, I feel like I'm doing something wrong and perhaps Array#select is not the appropriate method for this task. Thank you so much in advance for your help.
Code:
inventory = File.read('inventory_with_50k_names_and_associate_tag.csv')
# Since my CSV is headerless, I'm forcing manual headers
#dictionary_data = CSV.parse(inventory).map do |name|
Hash[ [:name, :tag].zip(name) ]
end
# ...
# API calls to my app to return an array of hashes is not shown (returns '#app_data')
# ...
#app_data.each do |issue|
# Extract base server name from FQDN (e.g. server_name1.sub.uk => server_name1)
derived_name = issue['name'].split('.').first
# THIS IS THE BLOCK OF CODE that slows down execution 30 fold:
#dictionary_data.select do |src_server|
issue['tag'] = src_server[:tag] if src_server[:asset_name].start_with?(derived_name)
end
end
Sample Data Returned from REST API (#app_data):
#app_data = [{'name' => 'server_name1.sub.emea', 'tag' => 'Europe', 'state' => 'Online'}
{'name' => 'server_name2.sub.us', 'tag' => 'US E.', 'state' => 'Online'}
{'name' => 'server_name3.sub.us', 'tag' => 'US W.', 'state' => 'Failover'}]
Sample Dictionary Hash Content:
#dictionary_data = [{:asset_name => 'server_name1-X98765432', :tag => 'Paris, France'}
{:asset_name => 'server_name2-Y45678920', :tag => 'New York, USA'}
{:asset_name => 'server_name3-Z34534224', :tag => 'Portland, USA'}]
Desired Output:
#app_data = [{'name' => 'server_name1', 'tag' => 'Paris, France', 'state' => 'Up'}
{'name' => 'server_name2', 'tag' => 'New York, USA', 'state' => 'Up'}
{'name' => 'server_name3', 'tag' => 'Portland, USA', 'state' => 'F.O'}]
Assuming "no" on both of my questions in the comments:
#!/usr/bin/env ruby
require 'csv'
#dictionary_data = CSV.open('dict_data.csv') { |csv|
Hash[csv.map { |name, tag| [name[/^.+(?=-\w+$)/], tag] }]
}
#app_data = [{'name' => 'server_name1.sub.emea', 'tag' => 'Europe', 'state' => 'Online'},
{'name' => 'server_name2.sub.us', 'tag' => 'US E.', 'state' => 'Online'},
{'name' => 'server_name3.sub.us', 'tag' => 'US W.', 'state' => 'Failover'}]
STATE_MAP = {
'Online' => 'Up',
'Failover' => 'F.O.'
}
#app_data = #app_data.map do |server|
name = server['name'][/^[^.]+/]
{
'name' => name,
'tag' => #dictionary_data[name],
'state' => STATE_MAP[server['state']],
}
end
p #app_data
# => [{"name"=>"server_name1", "tag"=>"Paris, France", "state"=>"Up"},
# {"name"=>"server_name2", "tag"=>"New York, USA", "state"=>"Up"},
# {"name"=>"server_name3", "tag"=>"Portland, USA", "state"=>"F.O."}]
EDIT: I find it more convenient here to read the CSV without headers, as I don't want it to generate an array of hashes. But to read a headerless CSV as if it had headers, you don't need to touch the data itself, as Ruby's CSV is quite powerful:
CSV.read('dict_data.csv', headers: %i(name tag)).map(&:to_hash)
I try with following code but i am getting error,
server = connection.servers.create({
:name => "instance-#{Time.now}",
:image_name => "debian-7-wheezy-v20150325",
:machine_type => "f1-micro",
:zone_name => "us-central1-a",
})
/home/vijay/.rvm/gems/ruby-2.0.0-p598/gems/fog-core-1.30.0/lib/fog/core/attributes.rb:151:in `requires': disks is required for this operation (ArgumentError)
from /home/vijay/.rvm/gems/ruby-2.0.0-p598/gems/fog-1.29.0/lib/fog/google/models/compute/server.rb:218:in `save'
from /home/vijay/.rvm/gems/ruby-2.0.0-p598/gems/fog-core-1.30.0/lib/fog/core/collection.rb:51:in `create'
from google_compute_engine.rb:11:in `<main>'
I think i am missing some parameter which is required, can someone help me to solve this problem.
First create a disk:
disk = connection.disks.create({
:name => "my-disk",
:zone_name => "us-central1-a",
:size_gb => 10,
:source_image => "debian-7-wheezy-v20150325"})
Next create the instance with that disk:
server = connection.servers.create({
:name => "my-server",
:machine_type => "f1-micro",
:zone_name => "us-central1-a",
:disks => [disk.get_as_boot_disk]})
Note you can attach multiple disks at instance creation.
I've already banged my head to the wall trying to set up debug process on Vagrant virtual machine.
I've got Windows 8.1 on my host machine and Ubuntu 14 onthe guest machine.
Here is my xdebug.ini:
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_log=/var/xdebug.log
xdebug.remote_host="10.0.2.2"
xdebug.remote_port="8000"
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_handler="dbgp"
xdebug.idekey=vagrant
But in a log file I see such message:
Log opened at 2014-11-13 04:32:18
I: Checking remote connect back address.
I: Remote address found, connecting to 10.10.10.1:9000.
E: Time-out connecting to client. :-(
Log closed at 2014-11-13 04:32:18
Why there are different ip and port?
I've searched around where it can be overwritten, but no luck. In php.ini I found nothing.
Also strange thing: in my path mapping settings at PHPStorm I have slashes replaced by backslahes. I don't know, is it come to a problem.
EDIT: Here is result of php -i | grep xdebug
24:/etc/php5/cli/conf.d/20-xdebug.ini,
47: with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
767:xdebug
769:xdebug support => enabled
777:xdebug.auto_trace => Off => Off
778:xdebug.cli_color => 0 => 0
779:xdebug.collect_assignments => Off => Off
780:xdebug.collect_includes => On => On
781:xdebug.collect_params => 0 => 0
782:xdebug.collect_return => Off => Off
783:xdebug.collect_vars => Off => Off
784:xdebug.coverage_enable => On => On
785:xdebug.default_enable => On => On
786:xdebug.dump.COOKIE => no value => no value
787:xdebug.dump.ENV => no value => no value
788:xdebug.dump.FILES => no value => no value
789:xdebug.dump.GET => no value => no value
790:xdebug.dump.POST => no value => no value
791:xdebug.dump.REQUEST => no value => no value
792:xdebug.dump.SERVER => no value => no value
793:xdebug.dump.SESSION => no value => no value
794:xdebug.dump_globals => On => On
795:xdebug.dump_once => On => On
796:xdebug.dump_undefined => Off => Off
797:xdebug.extended_info => On => On
798:xdebug.file_link_format => no value => no value
799:xdebug.idekey => vagrant => vagrant
800:xdebug.max_nesting_level => 100 => 100
801:xdebug.overload_var_dump => On => On
802:xdebug.profiler_aggregate => Off => Off
803:xdebug.profiler_append => Off => Off
804:xdebug.profiler_enable => Off => Off
805:xdebug.profiler_enable_trigger => Off => Off
806:xdebug.profiler_output_dir => /tmp => /tmp
807:xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
808:xdebug.remote_autostart => Off => Off
809:xdebug.remote_connect_back => On => On
810:xdebug.remote_cookie_expire_time => 3600 => 3600
811:xdebug.remote_enable => On => On
812:xdebug.remote_handler => dbgp => dbgp
813:xdebug.remote_host => 10.0.2.2 => 10.0.2.2
814:xdebug.remote_log => /var/xdebug.log => /var/xdebug.log
815:xdebug.remote_mode => req => req
816:xdebug.remote_port => 10000 => 10000
817:xdebug.scream => Off => Off
818:xdebug.show_exception_trace => Off => Off
819:xdebug.show_local_vars => Off => Off
820:xdebug.show_mem_delta => Off => Off
821:xdebug.trace_enable_trigger => Off => Off
822:xdebug.trace_format => 0 => 0
823:xdebug.trace_options => 0 => 0
824:xdebug.trace_output_dir => /tmp => /tmp
825:xdebug.trace_output_name => trace.%c => trace.%c
826:xdebug.var_display_max_children => 128 => 128
827:xdebug.var_display_max_data => 512 => 512
828:xdebug.var_display_max_depth => 3 => 3
Alright, so my problem has been resolved by setting remote_connect_back option to Off. Important note: I have used PuPHPet to generate Vagrant config file, and I didn't know, that there, in the PuPHPet config file, xDebug configuration dwells. Hence somehow host and port was always 10.10.10.10 and 9000 respectively. So it seems that all configurations have to be done by the initial Vagrant config, not by the SSH afterwards.
I am attempting to import a CSV file into my rails database (SQLite in Development) following this tutorial. Data is actually getting inserted into my database but it seems to only insert the first record from the CSV File. the rake seems to run without problem. and a running it with --trace reveals no additional information.
require 'csv'
desc "Import Voters from CSV File"
task :import => [:environment] do
file = "db/GOTV.csv"
CSV.foreach(file, :headers => false) do |row|
Voter.create({
:last_name => row[0],
:first_name => row[1],
:middle_name => row[2],
:name_suffix => row[3],
:primary_address => row[4],
:primary_city => row[5],
:primary_state => row[6],
:primary_zip => row[7],
:primary_zip4 => row[8],
:primary_unit => row[9],
:primary_unit_number => row[10],
:phone_number => row[11],
:phone_code => row[12],
:gender => row[13],
:party_code => row[14],
:voter_score => row[15],
:congressional_district => row[16],
:house_district => row[17],
:senate_district => row[18],
:county_name => row[19],
:voter_key => row[20],
:household_id => row[21],
:client_id => row[22],
:state_voter_id => row[23]
})
end
end
Just ran into this as well - guess you solved it some other way, but still might be useful for others.
In my case, the issue seems to be an incompatible change in the CSV library.
I guess you were using Ruby 1.8, where
CSV.foreach(path, rs = nil, &block)
The docs here are severely lacking, actually no docs at all, so have to guess from source: http://ruby-doc.org/stdlib-1.8.7/libdoc/csv/rdoc/CSV.html#method-c-foreach..
Anyway, 'rs' is clearly not an option hash, it looks like the record separator.
In Ruby 1.9 this is nicer: http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html#method-c-foreach
self.foreach(path, options = Hash.new, &block)
so this is the one that supports options such as :headers..