Skip to content

Commit 647a9ef

Browse files
Merge pull request #16 from RaizeTheLimit/docker_and_webauth
Docker support and simple web authentication
2 parents e825a84 + 20e3ef7 commit 647a9ef

9 files changed

Lines changed: 566 additions & 57 deletions

File tree

.dockerignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Build output
7+
dist/
8+
9+
# Proto samples (will be mounted as volume)
10+
proto_samples/
11+
12+
# Git
13+
.git/
14+
.gitignore
15+
.gitattributes
16+
17+
# Documentation
18+
*.md
19+
README*
20+
CHANGELOG*
21+
LICENSE*
22+
23+
# IDE
24+
.vscode/
25+
.idea/
26+
*.swp
27+
*.swo
28+
*~
29+
30+
# OS
31+
.DS_Store
32+
Thumbs.db
33+
34+
# Environment
35+
.env
36+
.env.*
37+
38+
# Testing
39+
coverage/
40+
.nyc_output/
41+
42+
# Docker
43+
Dockerfile
44+
docker-compose.yml
45+
.dockerignore
46+
47+
# CI/CD
48+
.github/
49+
.gitlab-ci.yml
50+
.travis.yml
51+
52+
# Misc
53+
*.log
54+
tmp/
55+
temp/

Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Stage 1: Build
2+
FROM node:20-alpine AS builder
3+
4+
# Install Yarn globally
5+
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
6+
7+
# Set working directory
8+
WORKDIR /app
9+
10+
# Copy package files
11+
COPY package.json yarn.lock ./
12+
13+
# Install all dependencies (including devDependencies for build)
14+
# Skip scripts to prevent prepare hook from running before source is copied
15+
RUN yarn install --frozen-lockfile --ignore-scripts
16+
17+
# Copy source code
18+
COPY . .
19+
20+
# Build the application (compile TypeScript + copy static assets)
21+
RUN yarn build
22+
23+
# Stage 2: Production
24+
FROM node:20-alpine
25+
26+
# Install Yarn globally
27+
RUN corepack enable && corepack prepare yarn@1.22.22 --activate
28+
29+
# Set working directory
30+
WORKDIR /app
31+
32+
# Copy package files
33+
COPY package.json yarn.lock ./
34+
35+
# Install only production dependencies
36+
# Skip scripts since we're only copying pre-built artifacts
37+
RUN yarn install --frozen-lockfile --production --ignore-scripts
38+
39+
# Copy built application from builder stage
40+
COPY --from=builder /app/dist ./dist
41+
42+
# Copy config directory structure (for config.json mount point)
43+
# Note: example.config.json is already in dist/config/ from the build process
44+
# This ensures the directory structure exists for the volume mount
45+
COPY --from=builder /app/dist/config/example.config.json ./dist/config/
46+
47+
# Create proto_samples directory
48+
RUN mkdir -p proto_samples
49+
50+
# Expose the default port
51+
EXPOSE 8081
52+
53+
# Set NODE_ENV to production
54+
ENV NODE_ENV=production
55+
56+
# Health check
57+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
58+
CMD node -e "require('http').get('http://localhost:8081/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
59+
60+
# Start the application
61+
CMD ["node", "dist/index.js"]

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
protodecoder-ui:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
container_name: protodecoder-ui
7+
ports:
8+
- "8081:8081"
9+
volumes:
10+
- ./src/config/config.json:/app/dist/config/config.json:ro
11+
- ./proto_samples:/app/proto_samples
12+
restart: unless-stopped
13+
environment:
14+
- NODE_ENV=production
15+
healthcheck:
16+
test: ["CMD", "node", "-e", "require('http').get('http://localhost:8081/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
17+
interval: 30s
18+
timeout: 10s
19+
start_period: 5s
20+
retries: 3

src/config/example.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"default_port": 8081,
3+
"web_password": null,
34
"trafficlight_identifier": "AwesomeProtoSender",
45
"redirect_to_golbat_url": null,
56
"redirect_to_golbat_token": null,

0 commit comments

Comments
 (0)