Surnet / docker-wkhtmltopdf

wkhtmltopdf for multiple base images
https://hub.docker.com/u/surnet/
MIT License
361 stars 65 forks source link

Alpine 3.11 image #13

Closed keeguon closed 4 years ago

keeguon commented 4 years ago

Will you be providing Alpine 3.11 based images in the future ?

chdanielmueller commented 4 years ago

I recently tried to build one without changing the Dockerfile. But unfortunately the build does not work without any changes.

If you are interested in trying to find out the error why it does not build feel free to do so and open a PR. I'm a bit busy at the moment and cannot do it myself

keeguon commented 4 years ago

@chdanielmueller I will take a look over the weekend and get back to you ;)

chdanielmueller commented 4 years ago

Perfect. Thank you

wanghanlin commented 4 years ago

I'm facing same issue with alpine 3.11, it seems related to g++ 9.2.0 in alpine 3.11.

I tested by changing g++ in Dockerfile to g++==8.3.0-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.10/main and it can build successfully (see log here), tested with docker run google.com - > test.pdf and it's working as expected.

Also libstdc++ and it's dependency libgcc are also using 9.2.0, but since the build is success, I didn't force install 8.3.0 from v3.10 repo.

As this is more like a hack instead of a fix, probably I won't submit a PR for this, but if you'd like to release with alpine 3.11 for other reason (like use a new version of php), I'm happy to commit this change.

adm-bome commented 4 years ago

I did not solve the problem! But dit some research....

The problem with the 3.11 image of alpine is that it uses g++ 9.20.

QT4.8 in the repository of wkhtmtopdf is not compatible wit gcc9.

This does not solve the problem entirely. The qmake command still gives an error. So wkhtmltopdf can't be build.

To build QT with no errors apply an extra patch qt-gcc9-foreach.patch:

--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -2482,22 +2482,32 @@ typedef uint Flags;

 #endif /* Q_NO_TYPESAFE_FLAGS */

-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
+#if (defined(Q_CC_GNU) && !defined(Q_CC_RVCT))
 /* make use of typeof-extension */
 template <typename T>
 class QForeachContainer {
 public:
-    inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
+    inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
     const T c;
     int brk;
     typename T::const_iterator i, e;
+    int control;
 };

+// Explanation of the control word:
+//  - it's initialized to 1
+//  - that means both the inner and outer loops start
+//  - if there were no breaks, at the end of the inner loop, it's set to 0, which
+//    causes it to exit (the inner loop is run exactly once)
+//  - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
+//    the outer loop to continue executing
+//  - if there was a break inside the inner loop, it will exit with control still
+//    set to 1; in that case, the outer loop will invert it to 0 and will exit too
 #define Q_FOREACH(variable, container)                                \
 for (QForeachContainer<__typeof__(container)> _container_(container); \
-     !_container_.brk && _container_.i != _container_.e;              \
-     __extension__  ({ ++_container_.brk; ++_container_.i; }))                       \
-    for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
+     _container_.control && _container_.i != _container_.e;         \
+     ++_container_.i, _container_.control ^= 1)                     \
+    for (variable = *_container_.i; _container_.control; _container_.control = 0)

 #else
mareksuscak commented 4 years ago

I just submitted 2 PRs that are adding support for Alpine 3.11 and 3.12. I spent this afternoon trying to get wkhtmltopdf 0.12.6 to compile on Alpine 3.11 and 3.12 with the default version of g++ but haven't had much success. However, as a workaround until these issues get sorted out, installing an older version of g++ and stdlibc++ from Alpine 3.10's package repository does the trick.

When you get a chance, could you please build and push these new images @chdanielmueller? Many thanks! 🙏

chdanielmueller commented 4 years ago

Hi @mareksuscak

I am currently in the process of building the images in your PRs. They will probably be up today. Thank you for your effort.

I also tagged your third PR with "help wanted". Feel free to open an issue if you think this will get more people to see it. I would be fine with waiting for wkhtmltopdf 0.12.7 which should include official alpine support: https://github.com/wkhtmltopdf/packaging/issues/2#issuecomment-645398170