FROM alpine:latest

# Install necessary packages
RUN apk add --no-cache \
    openvpn \
    squid \
    curl \
    bash \
    iptables \
    ip6tables \
    net-tools \
    procps \
    && rm -rf /var/cache/apk/*

# Create directories
RUN mkdir -p /etc/openvpn /var/log/squid /var/cache/squid /var/run/squid

# Copy configuration files
COPY squid.conf /etc/squid/squid.conf
COPY start.sh /start.sh
COPY version /version

# Make scripts executable
RUN chmod +x /start.sh

# Expose proxy port
EXPOSE 3128

# Set environment variables
ENV PROXY_URL=""
ENV VPN_CONFIG=""
ENV VPN_TYPE="openvpn"

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:3128/ || exit 1

# Start the service
CMD ["/start.sh"]
