This commit is contained in:
Mats Tornberg
2025-11-22 15:51:26 +01:00
parent 60f5783a26
commit 00f236cac7
27 changed files with 6319 additions and 67 deletions

View File

@@ -4,12 +4,16 @@ FROM golang:1.25.4-bookworm
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libssl-dev \
libavahi-client-dev \
libglib2.0-dev \
libftdi-dev \
libconfuse-dev \
wget \
unzip \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# Build telldus-core
COPY ./telldus-core /usr/src/telldus-core
WORKDIR /usr/src/telldus-core
RUN cmake . \
@@ -20,15 +24,43 @@ RUN cmake . \
# Set workdir for the project
WORKDIR /go/src/app
# Copy go mod and download dependencies
COPY go.mod go.sum ./
RUN go mod download
ENV GO111MODULE=on
ENV CGO_ENABLED=1
# Copy source code
COPY . .
COPY go.mod .
COPY go.sum .
# Build the application
RUN go build -o main .
# Download dependencies
RUN go mod download
COPY main.go .
COPY telldus ./telldus
# Build the Go application
RUN go build main.go
# Build the frontend
COPY frontend ./frontend
WORKDIR ./frontend
RUN npm install
RUN npm run build
RUN cp -r dist /go/src/app/
# Set workdir back
WORKDIR /go/src/app
# Create startup script
RUN echo '#!/bin/bash\n\
/usr/local/sbin/telldusd --nodaemon &\n\
TELLDUSD_PID=$!\n\
./main &\n\
MAIN_PID=$!\n\
trap "kill $MAIN_PID $TELLDUSD_PID; exit" INT TERM\n\
wait $MAIN_PID\n\
kill $TELLDUSD_PID' > start.sh && chmod +x start.sh
EXPOSE 8080
# Run the application
CMD ["./main"]
CMD ["./start.sh"]