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

Dockerfile + docker-compose.yaml build/running #93

Merged

Conversation

marcellodesales
Copy link
Contributor

@marcellodesales marcellodesales commented Dec 17, 2020

Add Dockerfile for building with the latest and the docker-compose, building the site and running. The current version of the Dockerfile does not work! It fails... the container stops because of an error...

Instead of using the Dockerfile, we introduced a new Dockerfile with a different docker image with the latest version.

Test logs for current version of Dockerfile - broken

  • I think this is due to using an older version of hugo...
$ docker build -f dev.Dockerfile -t docsy-example-dev:latest .
...
...
 => => naming to docker.io/library/docsy-example-dev:latest                                                                                                                                                       0.0s

$ docker run --publish 1313:1313 --detach --mount src="$(pwd)",target=/home/docsy/app,type=bind docsy-example-dev:latest
675480225bab118b005b2ce4076949b83b401d57862a193db135900daa61ab8e

$ docker ps
CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS                    NAMES
675480225bab        docsy-example-dev:latest   "hugo server"       2 seconds ago       Up 2 seconds        0.0.0.0:1313->1313/tcp   sweet_snyder

$ curl 0.0.0.0:1313
curl: (7) Failed to connect to 0.0.0.0 port 1313: Connection refused

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

$ docker start 675480225bab
675480225bab

$ docker logs 675480225bab
Building sites … ERROR 2020/12/17 08:10:25 render of "section" failed: execute of template failed: template: blog/section.print.html:2:3: executing "main" at <partial "print/render" .>: error calling partial: execute of template failed: template: partials/print/render.html:10:4: executing "recurse-toc" at <partial "print/toc-li.html" (dict "sid" $sid "Page" .)>: error calling partial: "/home/docsy/app/themes/docsy/layouts/partials/print/toc-li.html:3:5": execute of template failed: template: partials/print/toc-li.html:3:5: executing "partials/print/toc-li.html" at <partial $tpl .>: error calling partial: partial "/print/toc-li-blog.html" not found
ERROR 2020/12/17 08:10:25 failed to render pages: render of "section" failed: execute of template failed: template: blog/section.print.html:2:3: executing "main" at <partial "print/render" .>: error calling partial: execute of template failed: template: partials/print/render.html:10:4: executing "recurse-toc" at <partial "print/toc-li.html" (dict "sid" $sid "Page" .)>: error calling partial: "/home/docsy/app/themes/docsy/layouts/partials/print/toc-li.html:3:5": execute of template failed: template: partials/print/toc-li.html:3:5: executing "partials/print/toc-li.html" at <partial $tpl .>: error calling partial: partial "/print/toc-li-blog.html" not found
Error: Error building site: TOCSS: failed to transform "scss/main.scss" (text/x-scss): SCSS processing failed: file "stdin", line 6, col 1: File to import not found or unreadable: ../vendor/bootstrap/scss/bootstrap.
Built in 3321 ms
Building sites … ERROR 2020/12/17 08:11:27 render of "section" failed: execute of template failed: template: blog/section.print.html:2:3: executing "main" at <partial "print/render" .>: error calling partial: execute of template failed: template: partials/print/render.html:10:4: executing "recurse-toc" at <partial "print/toc-li.html" (dict "sid" $sid "Page" .)>: error calling partial: "/home/docsy/app/themes/docsy/layouts/partials/print/toc-li.html:3:5": execute of template failed: template: partials/print/toc-li.html:3:5: executing "partials/print/toc-li.html" at <partial $tpl .>: error calling partial: partial "/print/toc-li-blog.html" not found
ERROR 2020/12/17 08:11:27 failed to render pages: render of "section" failed: execute of template failed: template: blog/section.print.html:2:3: executing "main" at <partial "print/render" .>: error calling partial: execute of template failed: template: partials/print/render.html:10:4: executing "recurse-toc" at <partial "print/toc-li.html" (dict "sid" $sid "Page" .)>: error calling partial: "/home/docsy/app/themes/docsy/layouts/partials/print/toc-li.html:3:5": execute of template failed: template: partials/print/toc-li.html:3:5: executing "partials/print/toc-li.html" at <partial $tpl .>: error calling partial: partial "/print/toc-li-blog.html" not found
Built in 764 ms
Error: Error building site: TOCSS: failed to transform "scss/main.scss" (text/x-scss): SCSS processing failed: file "stdin", line 6, col 1: File to import not found or unreadable: ../vendor/bootstrap/scss/bootstrap.

Build and start from docker-compose

  • Just using docker-compose simplifies the development process...
$ docker-compose up --build
Starting docsy-example_site_1 ... done
Attaching to docsy-example_site_1
site_1  | Start building sites …
site_1  |
site_1  |                    | FA | NO | EN
site_1  | -------------------+----+----+-----
site_1  |   Pages            | 18 | 76 | 46
site_1  |   Paginator pages  |  0 |  0 |  0
site_1  |   Non-page files   |  3 |  1 |  3
site_1  |   Static files     | 38 | 38 | 38
site_1  |   Processed images |  8 |  2 |  7
site_1  |   Aliases          |  3 |  0 |  3
site_1  |   Sitemaps         |  2 |  1 |  1
site_1  |   Cleaned          |  0 |  0 |  0
site_1  |
site_1  | Built in 837 ms
site_1  | Watching for changes in /src/{assets,content,layouts,package.json,themes}
site_1  | Watching for config changes in /src/config.toml, /src/themes/docsy/config.toml
site_1  | Environment: "DEV"
site_1  | Serving pages from memory
site_1  | Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
site_1  | Web Server is available at //localhost:1313/ (bind address 0.0.0.0)
site_1  | Press Ctrl+C to stop
  • Optionally, you can just use docker-compose up -d to detach the process from the terminal.

Open a new terminal and test it

$ curl -X HEAD -i localhost:1313
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 27590
Content-Type: text/html; charset=utf-8
Last-Modified: Thu, 17 Dec 2020 08:47:13 GMT
Date: Thu, 17 Dec 2020 08:47:25 GMT

@google-cla
Copy link

google-cla bot commented Dec 17, 2020

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@marcellodesales
Copy link
Contributor Author

@googlebot I signed it!

@google-cla
Copy link

google-cla bot commented Dec 17, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Add Dockerfile for building with the latest and the docker-compose,
building the site and running.

$ docker-compose up
Starting docsy-example_site_1 ... done
Attaching to docsy-example_site_1
site_1  | Start building sites …
site_1  |
site_1  |                    | FA | NO | EN
site_1  | -------------------+----+----+-----
site_1  |   Pages            | 18 | 76 | 46
site_1  |   Paginator pages  |  0 |  0 |  0
site_1  |   Non-page files   |  3 |  1 |  3
site_1  |   Static files     | 38 | 38 | 38
site_1  |   Processed images |  8 |  2 |  7
site_1  |   Aliases          |  3 |  0 |  3
site_1  |   Sitemaps         |  2 |  1 |  1
site_1  |   Cleaned          |  0 |  0 |  0
site_1  |
site_1  | Built in 837 ms
site_1  | Watching for changes in /src/{assets,content,layouts,package.json,themes}
site_1  | Watching for config changes in /src/config.toml, /src/themes/docsy/config.toml
site_1  | Environment: "DEV"
site_1  | Serving pages from memory
site_1  | Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
site_1  | Web Server is available at //localhost:1313/ (bind address 0.0.0.0)
site_1  | Press Ctrl+C to stop

Open a new terminal and test it

$ curl -X HEAD -i localhost:1313
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 27590
Content-Type: text/html; charset=utf-8
Last-Modified: Thu, 17 Dec 2020 08:47:13 GMT
Date: Thu, 17 Dec 2020 08:47:25 GMT
@marcellodesales marcellodesales force-pushed the bugfix/dockerfile-docker-compose-builder branch from bd80f02 to c65ffec Compare December 17, 2020 09:06
@LisaFC
Copy link
Collaborator

LisaFC commented Jan 5, 2021

@geriom do you want to take a look at this?

@marcellodesales
Copy link
Contributor Author

marcellodesales commented Jan 24, 2021

@LisaFC @geriom are you guys going to look at this? I don't want to keep this change on my personal branch. It would be nice to be integrated...

Copy link
Collaborator

@geriom geriom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay Marcello. Thank you for this, I tested it and it works perfectly.

Just a couple of suggestions:

  • Change the image name in the compose file.
  • Please update the README file with instructions to start and stop the container.

docker-compose.yaml Outdated Show resolved Hide resolved
@marcellodesales
Copy link
Contributor Author

@geriom I just pushed the changes requested!

  • docker image name to be generic: docsy/docsy-example
  • README: update with steps to build, run, clean the environment

Copy link
Collaborator

@geriom geriom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@geriom geriom merged commit 18f9ce1 into google:master Feb 5, 2021
@marcellodesales marcellodesales deleted the bugfix/dockerfile-docker-compose-builder branch May 7, 2024 16:51
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

Successfully merging this pull request may close these issues.

None yet

3 participants