The Joyent Community

A place where the Joyent community can gather, help each other out, and stay informed.

You are not logged in.

#1 2006-02-08 03:01:21

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Hide certain files from the public

I want to make my source for my site open for everyone to check out but I don't want them downloading my database password and other private information. I don't want to setup two repos, one for deploying and one for the public. It seems like to much work. I want everyone to be able to access everything but a couple of files.

Any ideas?

Offline

 

#2 2006-02-08 03:04:37

cch
Member
Registered: 2005-03-21
Posts: 675
Website  Expertise

Re: Hide certain files from the public

if you're accessing via http(s) you can set permissions per directory.

you should probably keep your database.yml off the repository. (keep a safe sample there, but customize it on deployment)

Offline

 

#3 2006-02-08 03:06:55

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

cch wrote:

if you're accessing via http(s) you can set permissions per directory.

you should probably keep your database.yml off the repository. (keep a safe sample there, but customize it on deployment)


I am... I was just worried about the database.yml and my switchtower recipe. Does this even NEED to be in the repo or even in the production app at all?

Offline

 

#4 2006-02-08 03:32:48

cch
Member
Registered: 2005-03-21
Posts: 675
Website  Expertise

Re: Hide certain files from the public

i don't know about switchtower. but if you keep it in some other dir just block access to it.

Offline

 

#5 2006-02-08 03:52:34

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

Shoot. I'm using ssh+svn. Hmmmm... to "customize it on deployment" work require a fancy switchtower method right? I'll try that.

Offline

 

#6 2006-02-08 04:09:18

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

Do you think this would work?

Code:

task :write_database_config, :roles => :app do

buffer = render(:template => <<DATABASE_CONFIG) production: adapter: sqlite3 database: /path/to/my/database.db DATABASE_CONFIG put buffer, "#{release_path}/config/database.yml"
end


Works, I'm half way there

Last edited by joshpeek (2006-02-08 04:49:01)

Offline

 

#7 2006-02-08 06:25:49

jason
a chief (i started this place)
From: San Francisco
Registered: 2004-06-01
Posts: 8824
Website  Expertise

Re: Hide certain files from the public

For some reason I think it just takes leaving it blank, like we do

[dev:/railsapphosting/scripts/TextSamurai.rb]
@readonly = r

to make something readable in a private repository

And for some reason I'm thinking that

[repos:/path/to/file.rb]

  • =

    Make the file.rb unreadable in an open repos
    ...

Offline

 

#8 2006-02-08 12:39:29

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

I've just set an ignore on database.yml and deploy.rb. That works for me. Now I need to recreate the repo (because of versions w/ my passwords are up there) and move to https.

Offline

 

#9 2006-02-08 13:37:51

mrmachine
Member
From: Sydney, Australia
Registered: 2004-12-09
Posts: 1724
Website  Expertise

Re: Hide certain files from the public

just make database.yml.default in the repos and tell people to rename and edit it in their working copy.

Offline

 

#10 2006-02-08 22:01:37

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

I can't get switchtower to deploy over https.

It stalls here.

Code:

out :: joshpeek.com (R)eject, accept (t)emporarily or accept (p)ermanently?


Plus lighttpd doesn't wana start from switchtower. I have to manually start it up from shell access.

Code:

Bad Gateway
The proxy server received an invalid response from an upstream server.

Last edited by joshpeek (2006-02-08 22:08:30)

Offline

 

#11 2006-02-08 22:25:01

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

Its done.

http://www.joshpeek.com/blog/2006/02/08/steal-my-blog

I'm stilling have those problems with https and switchtower restarting lighttpd.

Last edited by joshpeek (2006-02-08 22:25:22)

Offline

 

#12 2006-02-08 23:44:34

mcornick
Member
Registered: 2005-09-06
Posts: 93
Expertise

Re: Hide certain files from the public

FWIW, here's what I do to have my database.yml installed after Switchtower does its thing:


Code:

desc "After symlinking current version, install database.yml"
task :after_symlink do run "cp /home/#{user}/etc/#{application}-database.yml #{deploy_to}/current/config/database.yml"
end


Though your way would work too, of course...

Offline

 

#13 2006-02-09 00:23:10

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

mcornick wrote:

FWIW, here's what I do to have my database.yml installed after Switchtower does its thing:


Code:

desc "After symlinking current version, install database.yml"
task :after_symlink do run "cp /home/#{user}/etc/#{application}-database.yml #{deploy_to}/current/config/database.yml"
end


Though your way would work too, of course...


I actually like that way better. But why not just symlink to it instead of copying.

Here is my modification.

Code:

desc "After symlinking current version, install database.yml"
task :after_symlink do

run "ln -nfs #{shared_dir}/config/database.yml #{release_path}/config/database.yml"
end

Last edited by joshpeek (2006-02-09 00:41:44)

Offline

 

#14 2006-02-09 01:06:34

mcornick
Member
Registered: 2005-09-06
Posts: 93
Expertise

Re: Hide certain files from the public

joshpeek wrote:

I actually like that way better. But why not just symlink to it instead of copying.


Why not, indeed. Changed my code accordingly.

I'm also having issues w/ restarting lighttpd from switchtower, though. Much like explained here: http://wrath.rubyonrails.org/pipermail/ … 12244.html Every time I think I've fixed it, it fails again within a few deployments, so I've just avoided the frustration and manually restart lighttpd after every deployment (which unfortunately ruins the real reason for using switchtower, as far as I'm concerned, but whatever...)

Offline

 

#15 2006-02-09 01:22:54

joshpeek
Member
From: Chicago, IL
Registered: 2005-12-02
Posts: 375
Website  Expertise

Re: Hide certain files from the public

Yea, its a weird thing. It seems like everytime I have my txd shell open ready to restart lighty, its fine. If I don't it fails. LOL.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson