# Use Alpine Linux as the base image
FROM alpine:3.20

# Update and install Golang and Git
RUN apk update && apk add --no-cache go git

# Create a new user and switch to it
RUN adduser -D myuser
USER myuser

# Set the working directory
WORKDIR /home/myuser

# Clone the Git repository
RUN git clone https://weforge.xyz/Spitfire/Search.git

# Change directory to the cloned repository
WORKDIR /home/myuser/Search

# Ensure the run.sh script is executable
RUN chmod +x run.sh

# Expose the application's port
EXPOSE 5000

# Define environment variables for port and domain with default values
ENV PORT=
ENV DOMAIN=
ENV SKIP_CONFIG="--skip-config-check"

# Run the run.sh script on container start
CMD ["sh", "-c", "./run.sh $SKIP_CONFIG --port ${PORT:-} --domain ${DOMAIN:-}"]