diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4a246ec --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +.dockerignore diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..bc1f238 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,35 @@ +--- +name: Publish + +on: + push: + branches: + - "master" + + # Allows to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + IMAGE_NAME: "node9/runtime" + +jobs: + publish: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: | + ${{env.IMAGE_NAME}}:${{github.sha}} + ${{env.IMAGE_NAME}}:0.0.${{github.run_number}} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d1eb805 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# Using Ubuntu LTS to avoid dependency churn +FROM ubuntu:20.04 as build + +ENV PREMAKE_URL https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-linux.tar.gz + +# install dependencies +RUN apt update +RUN apt install -y gcc make autoconf automake git wget libtool +RUN wget -O- $PREMAKE_URL | tar -C /bin -xzvf - + +# copy source +COPY . /node9 + +# build libuv +WORKDIR /node9/libuv +RUN sh autogen.sh && ./configure +RUN make -j "$(getconf _NPROCESSORS_ONLN)" +RUN rm .libs/lib*.so* # forcing static build + +# build luajit +WORKDIR /node9/luajit +RUN make -j "$(getconf _NPROCESSORS_ONLN)" +RUN rm src/lib*.so* # forcing static build + +# build node9 +WORKDIR /node9 +RUN premake5 gmake +# FIXME: there must be a way to tell premake to do this +RUN sed -i_ -e 's#^ndate:#ndate: lib9#' -e 's#^libnode9:#libnode9: ndate#' -e 's#^node9:#node9: libnode9#' Makefile +RUN make config=debug_linux -j "$(getconf _NPROCESSORS_ONLN)" + +# Finally, build the runtime environment +FROM ubuntu:20.04 + +COPY --from=build /node9/bin/* /bin/ +COPY --from=build /node9/lib/* /lib/ +COPY --from=build /node9/fs /fs + +# define entry point +WORKDIR / +ENV LD_LIBRARY_PATH /node9/lib +ENTRYPOINT ["/bin/node9"]