FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
ENV GO_VERSION=1.23.0
ENV APPIMAGE_TOOL_VERSION=13

RUN apt-get update && apt-get install -y ca-certificates && \
    sed -i 's|http://archive.ubuntu.com|https://archive.ubuntu.com|g' /etc/apt/sources.list && \
    sed -i 's|http://security.ubuntu.com|https://security.ubuntu.com|g' /etc/apt/sources.list && \
    apt-get update && apt-get install -y \
    wget curl git \
    gcc g++ \
    libgl1-mesa-dev \
    libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
    libxxf86vm-dev \
    pkg-config \
    fuse libfuse2 \
    file \
    && rm -rf /var/lib/apt/lists/*

# Install Go
RUN wget -q https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
    && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
    && rm go${GO_VERSION}.linux-amd64.tar.gz

ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/root/go"

# Install linuxdeploy + AppImage plugin
RUN wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \
    && chmod +x linuxdeploy-x86_64.AppImage \
    && mv linuxdeploy-x86_64.AppImage /usr/local/bin/linuxdeploy

WORKDIR /build
