tabixio / tabix

Tabix.io UI
https://tabix.io
Other
2.17k stars 264 forks source link

Dockerfile for building a Tabix Docker image #261

Open rikonor opened 1 year ago

rikonor commented 1 year ago

Hi,

I've had to do this a few times in the past, so just putting this here for reference in case someone finds it useful.

FROM ubuntu:22.04

RUN \
    apt-get update && \
    apt-get install -y \
        curl \
        unzip

RUN \
    curl -fsSL https://deb.nodesource.com/setup_lts.x | sh - && \
    apt-get install -y nodejs && \
    npm i -g yarn

WORKDIR /tmp

ADD \
    https://github.com/tabixio/tabix/archive/refs/heads/master.zip .

RUN \
    unzip master.zip && rm master.zip && \
    cd tabix-master && \
    echo 'nodeLinker: node-modules' > .yarnrc.yml && \
    yarn set version 3.1.1 && \
    yarn install && \
    yarn build

WORKDIR /tmp/tabix-master/dist

CMD [ "python3", "-m", "http.server" ]

Build with docker build -t tabix . and run with docker run --it -p 8000:8000 tabix.

rikonor commented 1 year ago

Smaller image version:

FROM ubuntu:22.04 AS builder

RUN \
    apt-get update && \
    apt-get install -y \
        curl \
        unzip

RUN \
    curl -fsSL https://deb.nodesource.com/setup_lts.x | sh - && \
    apt-get install -y nodejs && \
    npm i -g yarn

WORKDIR /tmp

ADD \
    https://github.com/tabixio/tabix/archive/refs/heads/master.zip .

RUN \
    unzip master.zip && rm master.zip && \
    cd tabix-master && \
    echo 'nodeLinker: node-modules' > .yarnrc.yml && \
    yarn set version 3.1.1 && \
    yarn install && \
    yarn build

FROM python:alpine

COPY --from=builder \
    /tmp/tabix-master/dist \
    /tabix

WORKDIR /tabix

CMD [ "python3", "-m", "http.server" ]
fufar commented 1 year ago

for me versions above didn't worked untill i set up port in CMD

FROM ubuntu:22.04

RUN \
    apt-get update && \
    apt-get install -y \
        curl \
        unzip

RUN \
    curl -fsSL https://deb.nodesource.com/setup_lts.x | sh - && \
    apt-get install -y nodejs && \
    npm i -g yarn

WORKDIR /tmp

ADD \
    https://github.com/tabixio/tabix/archive/refs/heads/master.zip .

RUN \
    unzip master.zip && rm master.zip && \
    cd tabix-master && \
    echo 'nodeLinker: node-modules' > .yarnrc.yml && \
    yarn set version 3.1.1 && \
    yarn install && \
    yarn build

WORKDIR /tmp/tabix-master/dist

CMD [ "python3", "-m", "http.server", "8000" ]
autokilla47 commented 5 months ago

i have a error:

....
0.704 error This project's package.json defines "packageManager": "yarn@3.1.1". However the current global version of Yarn is 1.22.22.
0.704
0.704 Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
0.704 Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.
------
Dockerfile-v2:19
--------------------
  18 |
  19 | >>> RUN \
  20 | >>>     unzip master.zip && rm master.zip && \
  21 | >>>     cd tabix-master && \
  22 | >>>     echo 'nodeLinker: node-modules' > .yarnrc.yml && \
  23 | >>>     yarn set version 3.1.1 && \
  24 | >>>     yarn install && \
  25 | >>>     yarn build
  26 |
autokilla47 commented 5 months ago

work for me:

FROM node:lts-slim AS builder

RUN apt-get  update  && \
    apt-get install -y \
    unzip && \
    corepack enable

WORKDIR /tmp

ADD \
    https://github.com/tabixio/tabix/archive/refs/heads/master.zip .

RUN \
    unzip master.zip && rm master.zip && \
    cd tabix-master && \
    echo 'nodeLinker: node-modules' > .yarnrc.yml && \
    yarn set version 3.1.1 && \
    yarn install && \
    yarn build

FROM python:alpine3.20

COPY --from=builder \
    /tmp/tabix-master/dist \
    /tabix

WORKDIR /tabix

CMD [ "python3", "-m", "http.server", "8000" ]