Skip to content

Commit

Permalink
fix: presist db between deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
goshatch committed Oct 10, 2024
1 parent b32bf48 commit d33e591
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
!Makefile
!src/
!cljs/
!db
!test/
!test-data/
!resources/
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ RUN apk add --no-cache \
jq~=1.7.1-r0

# Create Non-root group and user to run service securely
RUN addgroup -S clojure && adduser -S clojure -G clojure
RUN addgroup -g 1001 clojure && adduser -u 1001 -S clojure -G clojure

# Create directory to contain service archive, owned by non-root user
RUN mkdir -p /service && chown -R clojure. /service
RUN mkdir -p /app && chown -R clojure. /app

# Tell docker that all future commands should run as the appuser user
USER clojure

# Copy service archive file from Builder image
WORKDIR /service
COPY --from=builder /build/target/tools-ifs-parts-standalone.jar /service/
WORKDIR /app
COPY --from=builder /build/target/tools-ifs-parts-standalone.jar /app/

# Optional: Add System Integration testing scripts
# RUN mkdir -p /service/test-scripts
# COPY --from=builder /build/test-scripts/curl--* /service/test-scripts/
# RUN mkdir -p /app/test-scripts
# COPY --from=builder /build/test-scripts/curl--* /app/test-scripts/


# ------------------------
Expand Down Expand Up @@ -136,7 +136,7 @@ ENV JDK_JAVA_OPTIONS "-XshowSettings:system -XX:+UseContainerSupport -XX:MaxRAMP
# Start service using dumb-init and java run-time
# (overrides `jshell` entrypoint - default in eclipse-temuring image)
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["java", "-jar", "/service/tools-ifs-parts-standalone.jar"]
CMD ["java", "-jar", "/app/tools-ifs-parts-standalone.jar"]


# Docker Entrypoint documentation
Expand Down
3 changes: 3 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ services:
context: ./ # Use Dockerfile in project root
environment: # host:container
- COMPOSE_PROJECT_NAME
- PARTS_DB_PATH=/app/db/parts.db
ports: # host:container
- 3000:3000
volumes:
- ./db:/app/db
9 changes: 6 additions & 3 deletions config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ builder:
arch: amd64

# Inject ENV variables into containers (secrets come from .kamal/secrets).
#
# env:
# clear:
# DB_HOST: 192.168.0.2
# secret:
# - RAILS_MASTER_KEY
env:
clear:
PARTS_DB_PATH: /app/db/parts.db

# Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
# "bin/kamal logs -r job" will tail logs from the first server in the job section.
Expand All @@ -56,14 +58,15 @@ builder:

# Use a persistent storage volume.
#
# volumes:
volumes:
- /var/lib/parts-db:/app/db
# - "app_storage:/app/storage"

# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
# hitting 404 on in-flight requests. Combines all files from new and old
# version inside the asset_path.
#
# asset_path: /app/public/assets
# asset_path: /app/resources/public

# Configure rolling deploys by setting a wait time between batches of restarts.
#
Expand Down

0 comments on commit d33e591

Please sign in to comment.