You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there is no make target that enables me start the database together with air hot loading.
Either I can use make docker-run which does not support air hot loading, or I can use make watch which does not start the database.
I'd like to be able to start a development environment that supports both a database (as a test container like used for the tests or a regular docker image) together with the server with air hot loading support.
Disclaimer
I agree
The text was updated successfully, but these errors were encountered:
We can approach the solution in two different ways. One would be to simply add a target to the Makefile so that when make watch is executed, the database is also spun up:
watch: docker-run
@if command -v air > /dev/null; then \
air; \
echo "Watching...";\
...
Alternatively, we can achieve this using a Dockerfile and Docker Compose:
(This is just a code snippet to demonstrate the concept, the database part is not included.)
FROM golang:1.22-alpine AS base
RUN apk add --no-cache make
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
FROM base AS dev
RUN make build
EXPOSE 5000
CMD [ "sh", "-c", "echo 'y' | make watch" ]
FROM base AS build
RUN make build
FROM alpine:3.20.1 AS prod
WORKDIR /app
COPY --from=build /app/main /app/main
EXPOSE 5000
CMD ["./main"]
Tell us about your feature request
Currently there is no make target that enables me start the database together with air hot loading.
Either I can use
make docker-run
which does not support air hot loading, or I can usemake watch
which does not start the database.I'd like to be able to start a development environment that supports both a database (as a test container like used for the tests or a regular docker image) together with the server with air hot loading support.
Disclaimer
The text was updated successfully, but these errors were encountered: