Implement deploy strategy for local development; refactor container to use startup script.
This commit is contained in:
38
docker/Dockerfile
Normal file
38
docker/Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
||||
# Use a small Go base image
|
||||
FROM golang:1.24 AS builder
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /root
|
||||
|
||||
# Copy go mod and sum files
|
||||
COPY ../go.mod ../go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy the rest of the application
|
||||
COPY ../src/ ./src/
|
||||
COPY ../scripts/ ./scripts/
|
||||
RUN chmod +x /root/scripts/startup.sh
|
||||
|
||||
# Build the application
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o harbormaster ./src/
|
||||
|
||||
# Use a small base image for the final container
|
||||
FROM alpine:latest
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /root
|
||||
|
||||
# Copy the compiled binary from the builder stage
|
||||
COPY --from=builder /root/harbormaster .
|
||||
#COPY database/gold.db /root/database/gold.db
|
||||
#COPY migrations /root/migrations
|
||||
COPY ../scripts/ /root/scripts/
|
||||
RUN chmod +x /root/scripts/startup.sh
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
||||
# Run database setup and the binary
|
||||
CMD ["/bin/ash", "-c", "/root/scripts/startup.sh"]
|
||||
17
docker/docker-compose.dev.yml
Normal file
17
docker/docker-compose.dev.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
services:
|
||||
app:
|
||||
container_name: harbormaster-server
|
||||
image: harbormaster-server
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
target: builder
|
||||
volumes:
|
||||
- ../src:/root/src
|
||||
- ../scripts:/root/scripts
|
||||
ports:
|
||||
- "7080:8080"
|
||||
environment:
|
||||
- ENV=development
|
||||
# command: ["./harbormaster"]
|
||||
command: ["/bin/bash","/root/scripts/startup.sh"]
|
||||
Reference in New Issue
Block a user