Repository navigation
Expand file tree
/
Copy pathContainerfile
More file actions
90 lines (69 loc) · 2.67 KB
/
Copy pathContainerfile
File metadata and controls
90 lines (69 loc) · 2.67 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# SPDX-License-Identifier: MIT AND LicenseRef-Palimpsest-0.8
# SPDX-FileCopyrightText: 2024-2026 Jonathan D.A. Jewell and Contributors
#
# 1000Langs Containerfile (Podman-native)
# =======================================
# OCI-compliant container image for the parallel corpus crawler
# Build stage
FROM docker.io/library/node:20-alpine AS builder
LABEL org.opencontainers.image.title="1000Langs"
LABEL org.opencontainers.image.description="Super-parallel corpus crawler for multilingual NLP research"
LABEL org.opencontainers.image.source="https://github.com/Hyperpolymath/1000Langs"
LABEL org.opencontainers.image.licenses="MIT AND LicenseRef-Palimpsest-0.8"
LABEL org.opencontainers.image.vendor="Hyperpolymath"
WORKDIR /build
# Install build dependencies
RUN apk add --no-cache \
python3 \
make \
g++ \
git
# Copy package files
COPY package.json package-lock.json* rescript.json ./
# Install dependencies
RUN npm ci --ignore-scripts
# Copy source files
COPY src/ ./src/
COPY test/ ./test/
# Build ReScript
RUN npm run build
# Prune dev dependencies
RUN npm prune --production
# ============================================================================
# Production stage
# ============================================================================
FROM docker.io/library/node:20-alpine AS production
LABEL org.opencontainers.image.title="1000Langs"
LABEL org.opencontainers.image.description="Super-parallel corpus crawler for multilingual NLP research"
LABEL org.opencontainers.image.source="https://github.com/Hyperpolymath/1000Langs"
LABEL org.opencontainers.image.licenses="MIT AND LicenseRef-Palimpsest-0.8"
LABEL org.opencontainers.image.vendor="Hyperpolymath"
# Security: Create non-root user
RUN addgroup -g 1000 -S langs && \
adduser -u 1000 -S langs -G langs
WORKDIR /app
# Copy built artifacts and production dependencies
COPY --from=builder --chown=langs:langs /build/node_modules ./node_modules
COPY --from=builder --chown=langs:langs /build/src/*.mjs ./dist/
COPY --from=builder --chown=langs:langs /build/src/**/*.mjs ./dist/
# Copy static assets
COPY --chown=langs:langs meta/ ./meta/
COPY --chown=langs:langs config/ ./config/
# Create data directories
RUN mkdir -p /app/data /app/output /app/logs && \
chown -R langs:langs /app
# Security hardening
USER langs
# Environment
ENV NODE_ENV=production
ENV DATA_DIR=/app/data
ENV OUTPUT_DIR=/app/output
ENV LOG_DIR=/app/logs
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "console.log('healthy')" || exit 1
# Volumes for persistent data
VOLUME ["/app/data", "/app/output", "/app/logs"]
# Entry point
ENTRYPOINT ["node", "dist/Lang1000.res.mjs"]
CMD ["--help"]