# Build from source: compile a tiny program in a builder stage, then package in a runtime image
FROM alpine:3.19 AS builder
RUN apk add --no-cache build-base
WORKDIR /src
# Simple source file that simulates building from source
RUN cat > vpn_build.c <<'C'
#include <stdio.h>
int main() {
printf("3VPN container: built from source in container\n");
return 0;
}
C
# Compile the program
RUN gcc vpn_build.c -o vpn_build
FROM alpine:3.19 AS runtime
WORKDIR /vpn
# Copy the built artifact from the builder stage
COPY --from=builder /src/vpn_build /vpn/vpn_build
# Include the provided artifacts for distribution, including the APK and config if present
COPY 3VPN-release.apk /vpn/3VPN-release.apk
COPY config.json /vpn/config.json
COPY README.md /vpn/README.md
# Ensure the entrypoint is executable
RUN chmod +x /vpn/vpn_build
CMD ["/vpn/vpn_build"]