FROM golang:1.21-alpine AS base
  
# Set up dependencies
ENV PACKAGES git openssh-client build-base

# Install dependencies
RUN apk add --update $PACKAGES

# Add source files
RUN mkdir -p ./sdk-api

COPY ./ ./sdk-api/

FROM base AS build

RUN cd sdk-api && go mod tidy && go build -v -o /tmp/api ./cmd/api && go build -v -o /tmp/executor ./cmd/executor

FROM alpine

WORKDIR /app

COPY ./config.toml /config.toml

COPY --from=build /tmp/api /usr/bin/sdk_api

COPY --from=build /tmp/executor /usr/bin/sdk_executor

EXPOSE 8080