diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5df69eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +on: + push: + tags: + - v* + +env: + REGISTRY: ghcr.io + IMAGE_NAME: brittonhayes/psych + +jobs: + release-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c89b927 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +ARG GO_VERSION=1.21.6 + +# STAGE 1 +FROM golang:${GO_VERSION}-alpine AS builder + +WORKDIR /src/ + +COPY go.mod ./ +RUN go mod download + +COPY . /src/ +RUN CGO_ENABLED=0 go build -o /bin/psych cmd/psych/main.go + +# STAGE 2 +FROM gcr.io/distroless/static-debian11:nonroot + +LABEL maintainer="brittonhayes" +LABEL org.opencontainers.image.source="https://github.com/brittonhayes/psych" +LABEL org.opencontainers.image.description="Find a mental health professional." +LABEL org.opencontainers.image.licenses="MIT" + +COPY --from=builder --chown=nonroot:nonroot /bin/psych /bin/psych + +EXPOSE 8080 + +ENTRYPOINT [ "/bin/psych" ] + +CMD ["/bin/psych"] \ No newline at end of file diff --git a/README.md b/README.md index 8ba1375..dfbbbce 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,14 @@ Meet **Psych**, a Go application that allows you to find therapists from psychol go install github.com/brittonhayes/psych@latest ``` +### Install with Docker + +```bash + +```bash +docker run -p 8080:8080 ghcr.io/brittonhayes/psych -- api --port 8080 +``` + ## Usage Psych provides a set of commands to perform various tasks. Here's a brief overview: diff --git a/go.mod b/go.mod index 8493c78..4b10a9d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/brittonhayes/therapy -go 1.21.0 +go 1.21.6 require ( github.com/99designs/gqlgen v0.17.36