Skip to content

Instantly share code, notes, and snippets.

@xanderim
Created December 31, 2023 18:48
Show Gist options
  • Save xanderim/aa9910e9e272fbeb81d6d078a51321ac to your computer and use it in GitHub Desktop.
Save xanderim/aa9910e9e272fbeb81d6d078a51321ac to your computer and use it in GitHub Desktop.
Dockerfile: atlas with atlas-provider-gorm example
# Start from golang base image
FROM golang:1.21-alpine as builder
# Set the current working directory inside the builder stage
WORKDIR /app
# copy go mod
COPY ./backend/go.mod ./backend/go.sum ./
# Install atlas gorm provider
RUN go get -u ariga.io/atlas-provider-gorm
# Second stage
FROM alpine AS final
RUN apk update && apk add bash && apk add curl
# Download the script
RUN curl -sSf -o /tmp/atlas_install.sh https://atlasgo.sh
# Make the script executable
RUN chmod +x /tmp/atlas_install.sh
# Run the script
RUN /tmp/atlas_install.sh
# Set the current working directory inside the container
WORKDIR /app
# Copy the Golang binaries from the builder stage
COPY --from=builder /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"
# Copy the source code
COPY ./backend /app
# Copy other necessary files
COPY ./backend/migrations /migrations
COPY ./backend/atlas.hcl /atlas.hcl
COPY ./compose/production/go/wait_db.sh .
# Command to run the executable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment