Skip to content

Commit

Permalink
🔨 Update Loki
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoluisi committed Nov 22, 2023
1 parent 9b3839f commit 053e138
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .devspace/cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
varsEncrypted: true
lastContext:
namespace: template-java
context: docker-desktop
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
################ Build & Dev ################
# Build stage will be used:
# - for building the application for production
# - as target for development (see devspace.yaml)
FROM maven:3.8.7-openjdk-18-slim as base

FROM base as ci
# Create project directory (workdir)
WORKDIR /app
COPY . .

FROM ci as builder
WORKDIR /app
RUN mvn package -Dmaven.test.skip=true

FROM builder as shipment
################ Production ################
# Creates a minimal image for production using distroless base image
# More info here: https://github.com/GoogleContainerTools/distroless
# FROM builder as shipment
FROM gcr.io/distroless/java:11 as production
WORKDIR /app
COPY --from=builder /app/target/template-java.jar .
COPY --from=builder /app/target/app.jar .

ENTRYPOINT ["java","-jar", "/app/template-java.jar"]
# Application port (optional)
EXPOSE 8080

# Container start command for production
ENTRYPOINT ["java","-jar", "/app/app.jar"]
36 changes: 16 additions & 20 deletions devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: template-java

# `vars` specifies variables which may be used as ${VAR_NAME} in devspace.yaml
vars:
IMAGE: ghcr.io/devxp-tech/template-java:7df51a75 #:devspace
IMAGE: ghcr.io/devxp-tech/template-java

pipelines:
# Override the default pipeline for 'devspace dev'
Expand All @@ -16,13 +16,13 @@ pipelines:
# This is a list of `images` that DevSpace can build for this project
# We recommend to skip image building during development (devspace dev) as much as possible
images:
template-java:
app:
image: ${IMAGE}
dockerfile: ./Dockerfile

# This is a list of `deployments` that DevSpace can create for this project
deployments:
template-java:
app:
helm:
chart:
name: devxp-dev
Expand All @@ -37,37 +37,33 @@ deployments:
limits:
cpu: "200m"
memory: "512Mi"
envs:
- name: SERVICE_NAME
value: "template-java"
- name: INSECURE_MODE
value: "true"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: opentelemetry-collector.tracing.svc.cluster.local:4317

# This is a list of `dev` containers that are based on the containers created by your deployments
dev:
template-java:
app:
# Search for the container that runs this image
imageSelector: ${IMAGE}
# Replace the container image with this dev-optimized image (allows to skip image building during development)
devImage: ghcr.io/loft-sh/devspace-containers/go:1.18-alpine
# devImage: ghcr.io/loft-sh/devspace-containers/go:1.18-alpine
logs: {}
command:
- go
- run
- main.go
- mvn spring-boot:run
# Sync files between the local filesystem and the development container
sync:
- path: ./:/app
uploadExcludeFile: .dockerignore
excludePaths:
- "**"
- "!**/*.go"
- "!go.mod"
- "!go.sum"
- .git/
uploadExcludePaths:
- Dockerfile
- target/
onUpload:
restartContainer: true
execRemote:
onBatch:
command: sh
args:
- -c
- mvn compile >>/dev/pts/0 || exit 0
# Forward the following ports to be able access your application via localhost
ports:
- port: 23450:2345
Expand Down
26 changes: 26 additions & 0 deletions devspace_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

echo "Installing maven dependencies"

COLOR_CYAN="\033[0;36m"
COLOR_RESET="\033[0m"

echo -e "${COLOR_CYAN}
____ ____
| _ \ _____ __/ ___| _ __ __ _ ___ ___
| | | |/ _ \ \ / /\___ \| '_ \ / _\` |/ __/ _ \\
| |_| | __/\ V / ___) | |_) | (_| | (_| __/
|____/ \___| \_/ |____/| .__/ \__,_|\___\___|
|_|
${COLOR_RESET}
Welcome to your development container!
This is how you can work with it:
- Run \`${COLOR_CYAN}mvn spring-boot:run${COLOR_RESET}\` to run the application
- Run \`${COLOR_CYAN}mvn package -T 1C -U -Dmaven.test.skip=true${COLOR_RESET}\` to build the application
- ${COLOR_CYAN}Files will be synchronized${COLOR_RESET} between your local machine and this container (triggers build process)
- Some ports will be forwarded, so you can access this container on your local machine via ${COLOR_CYAN}localhost${COLOR_RESET}:"

devspace list ports

bash
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.devxp-tech</groupId>
<artifactId>template-java</artifactId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>template-java</name>
<description>Demo project for Spring Boot</description>
Expand Down

0 comments on commit 053e138

Please sign in to comment.