diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2d88d99 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,12 @@ +name: Fly Deploy +on: [push] +env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} +jobs: + deploy: + name: Deploy app + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy demo-app diff --git a/demo-app/Dockerfile b/demo-app/Dockerfile new file mode 100644 index 0000000..ae095ea --- /dev/null +++ b/demo-app/Dockerfile @@ -0,0 +1,37 @@ +# First stage: JDK build +FROM openjdk:17 AS build + +# Update package lists and Install Maven +RUN microdnf update -y && \ + microdnf install -y maven && \ + microdnf clean all + +WORKDIR /usr/src/app + +# Copy rest of the dependencies. +COPY pom.xml . +RUN mvn dependency:go-offline + +# Copy the source code +COPY . . + +## Do the build +RUN mvn clean install -Pproduction + +# Second stage: Lightweight jdk-slim image +FROM openjdk:17-jdk-slim +RUN useradd -m appuser + +RUN mkdir /app && \ + chown -R appuser /app + +USER appuser + +WORKDIR /app + +# Copy the native binary from the build stage +COPY --from=build /usr/src/app/target/idle-demo-*.jar /app/app.jar + +# Run the application +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "/app/app.jar"] \ No newline at end of file diff --git a/demo-app/fly.toml b/demo-app/fly.toml new file mode 100644 index 0000000..2c9e428 --- /dev/null +++ b/demo-app/fly.toml @@ -0,0 +1,12 @@ +app = "idle-demo" +primary_region = "fra" + +[env] +PORT = "8080" + +[http_service] +internal_port = 8080 +force_https = true +auto_stop_machines = true +auto_start_machines = true +min_machines_running = 0 \ No newline at end of file