Dockerfile added

This commit is contained in:
Frederik Löffert 2016-02-04 20:34:37 +01:00
parent 2a87819af9
commit d475331ae7
4 changed files with 74 additions and 68 deletions

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM scratch
COPY bin/contentserver-linux-amd64 /usr/sbin/contentserver
# install ca root certificates
# https://curl.haxx.se/docs/caextract.html
# http://blog.codeship.com/building-minimal-docker-containers-for-go-applications/
ADD https://curl.haxx.se/ca/cacert.pem /etc/ssl/certs/ca-certificates.crt
ENV CONTENT_SERVER_LOG_LEVEL=error
ENV CONTENT_SERVER_ADDR=0.0.0.0:80
ENV CONTENT_SERVER_PROTOCOL=tcp
ENV CONTENT_SERVER_VAR_DIR=/var/lib/contentserver
VOLUME $CONTENT_SERVER_VAR_DIR
EXPOSE 80
ENTRYPOINT ["/usr/sbin/contentserver"]
CMD ["-address=$CONTENT_SERVER_ADDR", "-logLevel=CONTENT_SERVER_LOG_LEVEL", "-protocol=$CONTENT_SERVER_PROTOCOL", "-vardir=$CONTENT_SERVER_VAR_DIR"]

View File

@ -1,11 +1,14 @@
SHELL := /bin/bash SHELL := /bin/bash
options: options:
echo "you can clean | test | build | run | package" echo "you can clean | test | build | build-arch | run | package"
clean: clean:
rm -f bin/content-server rm -fv bin/contentserve*
build: clean build: clean
go build -o bin/content-server go build -o bin/contentserver
build-arch: clean
GOOS=linux GOARCH=amd64 go build -o bin/contentserver-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o bin/contentserver-darwin-amd64
package: build package: build
pkg/build.sh pkg/build.sh
test: test:

View File

@ -1,65 +1,69 @@
# Content Server Content Server
==============
> Serves content tree structures very quickly through a json socket api > Serves content tree structures very quickly through a json socket api
## Concept Concept
-------
A Server written in GoLang to mix and resolve content from different content sources, e.g. CMS, Blog, Shop and many other more. The server provides a simple to use API for non blocking content repository updates, to resolve site content by an URI or to get deep-linking multilingual URIs for a given contentID. A Server written in GoLang to mix and resolve content from different content sources, e.g. CMS, Blog, Shop and many other more. The server provides a simple to use API for non blocking content repository updates, to resolve site content by an URI or to get deep-linking multilingual URIs for a given contentID.
It's up to you how you use it and which data you want to export to the server. Our intention was to write a fast and cache hazzle-free content server to mix different content sources. It's up to you how you use it and which data you want to export to the server. Our intention was to write a fast and cache hazzle-free content server to mix different content sources.
## Export Data Export Data
-----------
All you have to do is to provide a tree of content nodes as a JSON encoded RepoNode. All you have to do is to provide a tree of content nodes as a JSON encoded RepoNode.
| Attribute | Type | Usage |
| Attribute | Type | Usage | |---------------|:----------------------:|----------------------------------------------------------------------------------:|
| ------------- |:----------------------:| -----:| | Id | string | unique id to identify the node |
| Id | string | unique id to identify the node | | MimeType | string | mime-type of the node, e.g. text/html, image/png, ... |
| MimeType | string | mime-type of the node, e.g. text/html, image/png, ... | | LinkId | string | (symbolic) link/alias to another node |
| LinkId | string | (symbolic) link/alias to another node | | Groups | []string | access control |
| Groups | []string | access control | | URI | string | a map of unique URIs for each region and language to resolve and link to the node |
| URI | string | a map of unique URIs for each region and language to resolve and link to the node | | Name | string | a name for this node in every region and language |
| Name | string | a name for this node in every region and language | | Hidden | bool | hide in menu specific for region and language |
| Hidden | bool | hide in menu specific for region and language | | DestinationId | string | alias or symlink handling |
| DestinationId | string | alias or symlink handling | | Data | map[string]interface{} | payload data |
| Data | map[string]interface{} | payload data | | Nodes | map[string]*RepoNode | child nodes |
| Nodes | map[string]*RepoNode | child nodes | | Index | []string | contains the order of ou nodes |
| Index | []string | contains the order of ou nodes|
### Tips ### Tips
* If you do not want to build a multi-market website define a generic market, e.g. call it _universe_. - If you do not want to build a multi-market website define a generic market, e.g. call it *universe*.
* Do not export content which should not be accessible at all, e.g. you are working on a super secret fancy new category of your website. - Do not export content which should not be accessible at all, e.g. you are working on a super secret fancy new category of your website.
* Hidden nodes could be resolved by uri-requests, but are not served on a navigation node request. - Hidden nodes could be resolved by uri-requests, but are not served on a navigation node request.
* To make a node accessible only for a given region/language is totally easy, just set the region/language you want to serve. Other regions and languages will not contain this node any more. - To make a node accessible only for a given region/language is totally easy, just set the region/language you want to serve. Other regions and languages will not contain this node any more.
* To avoid duplicate content provide a DestinationId ( = ContentId of the node you want to reference) instead of URIs. - To avoid duplicate content provide a DestinationId ( = ContentId of the node you want to reference) instead of URIs.
## Request Data Request Data
------------
There is a PHP Proxy implementation for foomo in [Foomo.ContentServer](https://github.com/foomo/Foomo.ContentServer). Feel free to use it or to implement your own proxy in the language you love. The API should be easily to implement in every other framework and language, too. There is a PHP Proxy implementation for foomo in [Foomo.ContentServer](https://github.com/foomo/Foomo.ContentServer). Feel free to use it or to implement your own proxy in the language you love. The API should be easily to implement in every other framework and language, too.
## Usage Usage
-----
``` ```
$ content-server --help $ contentserver --help
Usage of bin/content-server: Usage of bin/contentserver:
-address="127.0.0.1:8081": address to bind host:port -address="127.0.0.1:8081": address to bind host:port
-logLevel="record": one of error, record, warning, notice, debug -logLevel="record": one of error, record, warning, notice, debug
-protocol="tcp": what protocol to server for -protocol="tcp": what protocol to server for
-vardir="127.0.0.1:8081": where to put my data -vardir="127.0.0.1:8081": where to put my data
``` ```
## Packaging & Deployment Packaging & Deployment
----------------------
In order to build packages and upload to Package Cloud, please install the following requirements and run the make task. In order to build packages and upload to Package Cloud, please install the following requirements and run the make task.
[Package Cloud Command Line Client](https://packagecloud.io/docs#cli_install) [Package Cloud Command Line Client](https://packagecloud.io/docs#cli_install)
``` ```
$ gem install package_cloud $ gem install package_cloud
``` ```
[FPM](https://github.com/jordansissel/fpm) [FPM](https://github.com/jordansissel/fpm)
@ -76,22 +80,27 @@ $ make package
*NOTE: you will be prompted for Package Cloud credentials.* *NOTE: you will be prompted for Package Cloud credentials.*
## Testing Testing
-------
``` ```
$ git clone https://github.com/foomo/contentserver.git $ git clone https://github.com/foomo/contentserver.git
$ cd content-server $ cd contentserver
$ make test $ make test
``` ```
## Contributing Contributing
------------
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests and examples for any new or changed functionality. In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests and examples for any new or changed functionality.
1. Fork it 1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`) 2. Create your feature branch (`git checkout -b my-new-feature`\)
3. Commit your changes (`git commit -am 'Add some feature'`) 3. Commit your changes (`git commit -am 'Add some feature'`\)
4. Push to the branch (`git push origin my-new-feature`) 4. Push to the branch (`git push origin my-new-feature`\)
5. Create new Pull Request 5. Create new Pull Request
## License License
Copyright (c) foomo under the LGPL 3.0 license. -------
Copyright (c) foomo under the LGPL 3.0 license.

26
Vagrantfile vendored
View File

@ -1,26 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
echo "Installing content-server..."
curl -s https://packagecloud.io/install/repositories/foomo/content-server/script.deb.sh | sudo bash
sudo apt-get install content-server
SCRIPT
Vagrant.configure("2") do |config|
config.vbguest.no_remote = true
config.vbguest.auto_update = false
config.vm.synced_folder ".", "/vagrant"
config.vm.define 'trusty' do |instance|
instance.vm.box = 'ubuntu/trusty64'
end
config.vm.define 'precise' do |instance|
instance.vm.box = 'ubuntu/precise64'
end
config.vm.provision "shell", inline: $script
end