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

Ponzu works fine locally but when I deploy it the content doesn't show up. #129

Closed
Nemesisesq opened this issue Apr 17, 2017 · 13 comments
Closed

Comments

@Nemesisesq
Copy link

Nemesisesq commented Apr 17, 2017

When I deploy ponzu with docker the ponzu build isn't creating the models properly so there are no contents on the admin page. When go to the type of the content that should be there. I get a 400

@nilslice
Copy link
Contributor

How are you doing the deployment? Could you outline the exact steps you're taking from your development environment to deploy?

@Nemesisesq
Copy link
Author

I have my elastic beanstalk set to deploy a zip with the app, a Dockerfile and a Dockerrun.aws.json file as well.

Here's my docker file

 FROM golang:1.8
 COPY startup.sh /startup.sh
 RUN go get github.com/ponzu-cms/ponzu/...
 RUN mkdir /app
 ADD . /app/

 RUN cd /app
 WORKDIR /app
 EXPOSE 8080
 RUN chmod -R 700 /startup.sh

 ENTRYPOINT ["/bin/bash", "/startup.sh"] 

startup.sh is

 #!/usr/bin/env bash

 ponzu build && ponzu run

@nilslice
Copy link
Contributor

Are you sure that the ADD . /app/ line is providing the files from the unzipped app to the container? It seems like the problem is that the content package files that you created are not being added. Maybe add a RUN ls /app/content line to see what is there at deploy time (assuming you can see the output of the docker build.)

@Nemesisesq
Copy link
Author

package content

import (
	"fmt"

	"github.com/ponzu-cms/ponzu/management/editor"
	"github.com/ponzu-cms/ponzu/system/item"
)

type Hello struct {
	item.Item

	World string `json:"world"`
}

// MarshalEditor writes a buffer of html to edit a Hello within the CMS
// and implements editor.Editable
func (h *Hello) MarshalEditor() ([]byte, error) {
	view, err := editor.Form(h,
		// Take note that the first argument to these Input-like functions
		// is the string version of each Hello field, and must follow
		// this pattern for auto-decoding and auto-encoding reasons:
		editor.Field{
			View: editor.Input("World", h, map[string]string{
				"label":       "World",
				"type":        "text",
				"placeholder": "Enter the World here",
			}),
		},
	)

	if err != nil {
		return nil, fmt.Errorf("Failed to render Hello editor view: %s", err.Error())
	}

	return view, nil
}

func init() {
	item.Types["Hello"] = func() interface{} { return new(Hello) }
}
 ---> 2e17051781b7
Removing intermediate container 64320a4ae687
Step 11/15 : RUN cat /app/content/tooltip.go
 ---> Running in 73e527f70e5a
package content

import (
	"fmt"

	"github.com/ponzu-cms/ponzu/management/editor"
	"github.com/ponzu-cms/ponzu/system/item"
)

type Tooltip struct {
	item.Item

	Name  string `json:"name"`
	Title string `json:"title"`
	Body  string `json:"body"`
}

// MarshalEditor writes a buffer of html to edit a Tooltip within the CMS
// and implements editor.Editable
func (t *Tooltip) MarshalEditor() ([]byte, error) {
	view, err := editor.Form(t,
		// Take note that the first argument to these Input-like functions
		// is the string version of each Tooltip field, and must follow
		// this pattern for auto-decoding and auto-encoding reasons:
		editor.Field{
			View: editor.Input("Name", t, map[string]string{
				"label":       "Name",
				"type":        "text",
				"placeholder": "Enter the Name here",
			}),
		},
		editor.Field{
			View: editor.Input("Title", t, map[string]string{
				"label":       "Title",
				"type":        "text",
				"placeholder": "Enter the Title here",
			}),
		},
		editor.Field{
			View: editor.Textarea("Body", t, map[string]string{
				"label":       "Body",
				"placeholder": "Enter the Body here",
			}),
		},
	)

	if err != nil {
		return nil, fmt.Errorf("Failed to render Tooltip editor view: %s", err.Error())
	}

	return view, nil
}

func init() {
	item.Types["Tooltip"] = func() interface{} { return new(Tooltip) }
}
 ---> a31788859947
Removing intermediate container 73e527f70e5a
Step 12/15 : RUN ls /app
 ---> Running in 1f39c0d12f71
Dockerfile
Dockerrun.aws.json
LICENSE
README.md
addons
analytics.db
bundle.zip
cmd
content
deployment
examples
ponzu-banner.png
startup.sh
system.db
uploads
 ---> 23b9f9ff7c8b
Removing intermediate container 1f39c0d12f71
Step 13/15 : RUN ponzu build
 ---> Running in 7b628e44a7db
 ---> da2ea12f0c53
Removing intermediate container 7b628e44a7db
Step 14/15 : RUN ls /app
 ---> Running in baa8a1921bad
Dockerfile
Dockerrun.aws.json
LICENSE
README.md
addons
analytics.db
bundle.zip
cmd
content
deployment
examples
ponzu-banner.png
ponzu-server
startup.sh
system.db
uploads
 ---> f65dc70016cd
Removing intermediate container baa8a1921bad
Step 15/15 : CMD ponzu run
 ---> Running in c1490deb8be5
 ---> 183d8e4c281b
Removing intermediate container c1490deb8be5
Successfully built 183d8e4c281b

@Nemesisesq
Copy link
Author

thats the output of the docker build locally

@nilslice
Copy link
Contributor

@Nemesisesq -
Are you expecting to see both the content/hello.go and content/tooltip.go? You pasted hello.go in the comment and then ran RUN cat /app/content/tooltip.go in the docker output.

Are you seeing either of them in your admin UI?

@Nemesisesq
Copy link
Author

I am not seeing them in the admin UI when I build and run the docker container. when I run ponzu build && ponzu run from my computer it worlds and I can see the contents in the UI. When I run docker locally it is not. I am making sure the container is building properly.

@nilslice
Copy link
Contributor

Is anything being restored from you local build? For example, do you need to re-initialize the CMS with your email / password./ CMS name / host etc? (indicating that system.db isn't loaded), or are the configuration setting all the same from local to docker?

@Nemesisesq
Copy link
Author

yeah I am not including system or analytics db. And I'm still not seeing hello or tooltip in the admin.

@nilslice
Copy link
Contributor

nilslice commented Apr 17, 2017

So the steps you are taking are these:

  1. bundle your local zip and deploy
  2. docker build with the unzipped app, ignoring the *.db files
  3. run ponzu, visit $YOUR_IP:8080/admin
  4. you're redirected to $YOUR_IP:8080/admin/init
  5. you fill out the initialization, and are redirected to $YOUR_IP:8080/admin
  6. nothing is listed in the Content section of your UI

Correct?

Do you have a .dockerignore file? If so, can you paste it in this thread?

@Nemesisesq
Copy link
Author

So I got it working inside docker I'm not exactly sure how. I think it had to do with how I was adding the directories. Is it possible to save the data to mongo db or something? or a db with some more persistence?

@Nemesisesq
Copy link
Author

Thank you for your help I really appreciate it.

@nilslice
Copy link
Contributor

Glad it is working for you! Happy to help.

You should try to create a volume (see docker docs) between your host and container so the db files persist between builds. We only support BoltDb as of now, but may consider adding optional db backends including mongo in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants