Skip to content

Commit 899e049

Browse files
committed
Docker setup
1 parent d36dafc commit 899e049

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

DockerfileCloudRun

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This Dockerfile is for Google Cloud Run deployment
2+
# See the grails-forge-web-netty subproject for the implementation
3+
4+
# Stage 1: Build the JAR
5+
FROM gradle:7.4.1 as gradle
6+
COPY --chown=gradle . /home/app
7+
WORKDIR /home/app
8+
RUN gradle grails-forge-web-netty:shadowJar --no-daemon
9+
RUN gradle grails-forge-analytics-postgres:jar --no-daemon
10+
11+
# Stage 2: Build the native image
12+
FROM ghcr.io/graalvm/graalvm-ce:java8-21.1.0 as graalvm
13+
COPY --from=gradle /home/app/grails-forge-web-netty/build/libs/*.jar /home/app/server.jar
14+
WORKDIR /home/app
15+
RUN gu install native-image
16+
RUN native-image --no-fallback -cp server.jar
17+
18+
# Stage 3: Prepare Server
19+
FROM adoptopenjdk/openjdk11:alpine-slim
20+
EXPOSE 8080
21+
COPY --from=graalvm /home/app/grails-forge /app/grails-forge
22+
ENTRYPOINT ["/app/grails-forge"]

docker-compose.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# A Docker Compose For running the Cloud Run image locally
2+
version: '3'
3+
services:
4+
postgres:
5+
image: postgres
6+
ports:
7+
- 5432:5432
8+
environment:
9+
POSTGRES_PASSWORD: mysecretpassword
10+
grails-forge:
11+
image: grails-forge
12+
links:
13+
- postgres
14+
ports:
15+
- 8080:8080
16+
environment:
17+
DATASOURCES_DEFAULT_URL: postgres
18+
DATASOURCES_DEFAULT_USERNAME: postgres
19+
DATASOURCES_DEFAULT_PASSWORD: mysecretpassword
20+

grails-forge-web-netty/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#FROM ghcr.io/graalvm/graalvm-ce:java8-21.0.0.2 as graalvm
2+
# For JDK 11
3+
FROM ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2 as graalvm
4+
RUN gu install native-image
5+
6+
COPY . /home/app/grails-forge
7+
WORKDIR /home/app/grails-forge
8+
9+
RUN native-image -cp build/libs/grails-forge-web-netty-*-all.jar
10+
11+
FROM adoptopenjdk/openjdk11:alpine-slim
12+
EXPOSE 8080
13+
COPY --from=graalvm /home/app/grails-forge/grails-forge /app/grails-forge
14+
ENTRYPOINT ["/app/grails-forge"]

sam-local.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: Grails Forge API - grails-forge::grails-forge
4+
Globals:
5+
Api:
6+
EndpointConfiguration: REGIONAL
7+
Resources:
8+
GrailsForgeFunction:
9+
Type: AWS::Serverless::Function
10+
Properties:
11+
Handler: not.used.in.provided.runtime
12+
Runtime: provided
13+
CodeUri: build/function.zip
14+
MemorySize: 128
15+
Policies: AWSLambdaBasicExecutionRole
16+
Timeout: 15
17+
Events:
18+
GetResource:
19+
Type: Api
20+
Properties:
21+
Path: /{proxy+}
22+
Method: any
23+
Outputs:
24+
MicronautStarterApi:
25+
Description: URL for application
26+
Value: !Sub 'https://${GrailsForgeFunction}.execute-api.${AWS::Region}.amazonaws.com/'
27+
Export:
28+
Name: GrailsForgeApi

0 commit comments

Comments
 (0)