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

Building Docker Alpine:3.7 #7

Closed
MetalBlueberry opened this issue Jan 13, 2018 · 10 comments
Closed

Building Docker Alpine:3.7 #7

MetalBlueberry opened this issue Jan 13, 2018 · 10 comments

Comments

@MetalBlueberry
Copy link

MetalBlueberry commented Jan 13, 2018

Hi all,

I'm trying to build the project using Docker with an image based in Alpine3.7.
here is the Dockerfile

FROM alpine:3.7 as builder
LABEL Name=td-builer Version=0.0.1

RUN apk update
RUN apk add --update alpine-sdk 
RUN apk add --update openssl-dev
RUN apk add --update cmake
RUN apk add --update gperf
RUN apk add --update zlib-dev

WORKDIR /
COPY ./td /td

WORKDIR /td
RUN mkdir build
WORKDIR build
RUN cmake ..
RUN cmake --build .
RUN cmake --build . --target install

I get the following error

[  5%] Building CXX object tdutils/CMakeFiles/tdutils.dir/td/utils/port/Stat.cpp.o
/td/tdutils/td/utils/port/Stat.cpp: In function 'td::Stat td::detail::from_native_stat(const stat&)':
/td/tdutils/td/utils/port/Stat.cpp:54:55: error: 'const struct stat' has no member named 'st_mtimensec'; did you mean 'st_mtim'?
   res.mtime_nsec_ = buf.st_mtime * 1000000000ll + buf.st_mtimensec;
                                                       ^~~~~~~~~~~~
/td/tdutils/td/utils/port/Stat.cpp:55:55: error: 'const struct stat' has no member named 'st_atimensec'; did you mean 'st_atim'?
   res.atime_nsec_ = buf.st_atime * 1000000000ll + buf.st_atimensec;
                                                       ^~~~~~~~~~~~
make[2]: *** [tdutils/CMakeFiles/tdutils.dir/build.make:255: tdutils/CMakeFiles/tdutils.dir/td/utils/port/Stat.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:556: tdutils/CMakeFiles/tdutils.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

I've found related issues in other projects
httpuv/issues/63
but I can't figure out how to apply it to this one.

Thank you!

@isopen
Copy link
Contributor

isopen commented Jan 14, 2018

Try to bypass the mountaineering with this
https://github.com/isopen/docker/blob/master/tdlib/Dockerfile.debian

@MetalBlueberry
Copy link
Author

Hi @isopen
That docker image is based on debian:9, thus it compiles without problem.
also, I can compile it using an ubuntu based image, but the idea is to use Alpine.
any other suggestion?

@isopen
Copy link
Contributor

isopen commented Jan 14, 2018

I understand that we are not looking for easy ways. We want to minimize the image :)
Then try this:

tdlib/td/tdutils/td/utils/port/Stat.cpp54:55
change it so:
func Stat from_native_stat(const struct ::stat &buf)
...
#else
  res.mtime_nsec_ = buf.st_mtime * 1000000000ll + buf.st_mtim.tv_nsec;
  res.atime_nsec_ = buf.st_atime * 1000000000ll + buf.st_atim.tv_nsec;
#endif
...

Then run https://github.com/isopen/docker/blob/master/tdlib/Dockerfile.alpine

@levlam
Copy link
Contributor

levlam commented Jan 15, 2018

As a workaround, you can add "|| 1" to line Stat.cpp:50:
#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700 || TD_EMSCRIPTEN || 1

We will rewrite that condition in more robust way.

@isopen
Copy link
Contributor

isopen commented Jan 15, 2018

Hi @MetalBlueberry
Do this in the sys/stat.h structure
st_mtimensec
st_atimensec
/usr/include/sys/stat.h package musl-dev
Works are not much :)))
image

@MetalBlueberry
Copy link
Author

Hi @isopen

Yesterday a let my computer compiling overnight with the fix

tdlib/td/tdutils/td/utils/port/Stat.cpp54:55
change it so:
func Stat from_native_stat(const struct ::stat &buf)
...
#else
  res.mtime_nsec_ = buf.st_mtime * 1000000000ll + buf.st_mtim.tv_nsec;
  res.atime_nsec_ = buf.st_atime * 1000000000ll + buf.st_atim.tv_nsec;
#endif
...

It got stuck at 100% with no error msg, but the processor was doing something.( 75%~ avg usage)
I think that it was a docker issue with the memory in my system, I'm using a laptop Intel Core i5-5200U with 4GB DDR3.
any way, I will try again with a better computer as soon as I have time.

Thank you for your time!

@isopen
Copy link
Contributor

isopen commented Jan 19, 2018

Try this bike: #6
On your computer should be -j 2, but the RAM will definitely take off and everything will hang on the n-th time interval.

I think ideally for a comfortable build you need 12 cores and 32GB RAM.
In order not to bother at all and not to peek, then 24 cores and 64GB RAM.
The iron market did not take off, but the processing volumes definitely took off.
But in practice, I can say with certainty that this iron can also be loaded, but not so often :)

Concerning the assembly under Alpine at the moment, @levlam suggested a more laconic solution, but the way of work will be the same.

@MetalBlueberry
Copy link
Author

I think that this issue can be closed.

@isopen
Copy link
Contributor

isopen commented Mar 10, 2018

You can reopen this report :) @levlam Not yet fixed
isopen/docker#2
isopen/docker#1

@levlam
Copy link
Contributor

levlam commented Mar 19, 2018

The issue should be fixed in TDLib 1.2.0.

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

3 participants