-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (50 loc) · 1.81 KB
/
Dockerfile
File metadata and controls
67 lines (50 loc) · 1.81 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# TimmyBot Dockerfile for AWS ECS Deployment (CDK-managed)
# Guild Isolation Architecture with AWS Integration
# Multi-stage build for optimized production container
FROM eclipse-temurin:17-jdk-alpine AS builder
# Install build dependencies
RUN apk add --no-cache \
curl \
unzip
# Copy Gradle wrapper and build files
WORKDIR /app
COPY gradlew .
COPY gradle gradle
COPY build.gradle.kts .
COPY settings.gradle .
# Copy source code
COPY src src
# Build the application (with fallback compilation strategy)
RUN chmod +x gradlew && \
./gradlew clean build --no-daemon --stacktrace || \
./gradlew jar --no-daemon --stacktrace
# Production stage
FROM eclipse-temurin:17-jre-alpine
# Install runtime dependencies
RUN apk add --no-cache \
curl \
ca-certificates \
procps
# Create non-root user for security
RUN addgroup -S timmybot && adduser -S timmybot -G timmybot
# Set working directory
WORKDIR /app
# Copy built JAR from builder stage
COPY --from=builder /app/build/libs/*.jar timmybot.jar
# Change ownership to non-root user
RUN chown -R timmybot:timmybot /app
# Switch to non-root user
USER timmybot
# Health check for Discord bot process
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD pgrep -f "java.*timmybot.jar" > /dev/null || exit 1
# Set memory options for container environment
ENV JAVA_OPTS="-Xmx512m -Xms256m -XX:+UseG1GC -XX:MaxGCPauseMillis=200"
# AWS Environment Variables (will be overridden by ECS task definition)
ENV AWS_DEFAULT_REGION=eu-central-1
ENV GUILD_QUEUES_TABLE=timmybot-dev-guild-queues
ENV SERVER_ALLOWLIST_TABLE=timmybot-dev-server-allowlist
ENV DISCORD_BOT_TOKEN_SECRET=timmybot/dev/discord-bot-token
# No ports exposed (Discord bot uses WebSocket connections)
# Run the application
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar timmybot.jar"]