-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (31 loc) · 920 Bytes
/
Dockerfile
File metadata and controls
46 lines (31 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Start from the official Golang image
FROM golang:1.22-alpine as builder
WORKDIR /app
# Install git (for go mod) and sqlite
RUN apk add --no-cache git build-base sqlite
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the rest of the source code
COPY . .
# Build the Go app
RUN go build -o jobscraper main.go
# Final image
FROM alpine:3.19
WORKDIR /app
# Install sqlite for the database
RUN apk add --no-cache sqlite
# Copy the built binary and static files
COPY --from=builder /app/jobscraper .
COPY static ./static
# Create folder for SQLite database and copy it there
RUN mkdir -p /var/www/db/
COPY jobs.db /var/www/db/jobs.db
# Add permissions for writable database
RUN chmod 777 /var/www/db
RUN chmod 666 /var/www/db/jobs.db
# Expose the port (change if your app uses a different port)
EXPOSE 8080
# Command to run the binary
CMD ["./jobscraper"]