forked from h-alice/TcgDocWriterService
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (40 loc) · 1.44 KB
/
Dockerfile
File metadata and controls
51 lines (40 loc) · 1.44 KB
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
47
48
49
50
51
#---------------------------------------------------------------------
# Stage 1: Build Stage (using a standard Haskell image)
#---------------------------------------------------------------------
# Use an official Haskell image with a specific GHC version for reproducibility
FROM haskell:9.6-slim AS builder
# Or use haskell:latest if you prefer
# Set the working directory inside the container
WORKDIR /app
# Copy stack.yaml and package.yaml or *.cabal and install dependencies
COPY stack.yaml stack.yaml.lock ./
COPY package.yaml ./
RUN stack setup && stack build --only-dependencies
# Copy all source files
COPY . .
# Build the application
RUN stack build --copy-bins
#---------------------------------------------------------------------
# Stage 2: Runtime Stage (using Alpine)
#---------------------------------------------------------------------
# Use a specific Alpine version for stability
FROM alpine:3.21 AS final
# Install necessary system libs (if needed)
RUN apk add --no-cache \
gmp \
libffi \
zlib \
libc6-compat \
libstdc++ \
libgcc
# --- Security Best Practice: Run as non-root user ---
# Create a group and user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Set the user for subsequent commands
USER appuser
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /app/bin/tcgdoc-serv-exe .
# Set port and command to run the app
EXPOSE 8080
CMD ["./tcgdoc-serv-exe"]