Skip to content

Commit

Permalink
Build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed Mar 25, 2023
1 parent d8d3f12 commit b4e4421
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
name: Gradle Build
on:
workflow_dispatch:
push:
branches: ["master"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
publish:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt-hotspot'

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: "publish"
arguments: "service:shadowJar publish"
env:
DEPLOY_USERNAME: ${{ secrets.DEPLOY_USERNAME }}
DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}

- name: Log in
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openjdk:17-alpine
# Create workspace
WORKDIR /usr/app
# Add build application jar
COPY service/build/libs/service-1.0-SNAPSHOT-all.jar ./service.jar

# Default to 8080
ENV APP_PORT 8080
EXPOSE 8080
# Start application
CMD ["java", "-jar", "service.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
@Slf4j
@Singleton
public class TermsRepository {
public static final String COLLECTION = "terms";

@Inject
Configuration config;

Expand Down
4 changes: 2 additions & 2 deletions service/src/main/resources/service.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

# Http server settings
http.host=0.0.0.0
http.port=8080
http.port=${APP_PORT:8080}

# Translations db path
translations-file=${TRANSLATIONS_FILE:translations.db}

# Access tokens divided by semicon
service.access-tokens=my_secret_token,my_secret_token2
service.access-tokens=${ACCESS_TOKEN:my_secret_token,my_secret_token2}

# Translations scrapper name
# Supported values: traduora
Expand Down

0 comments on commit b4e4421

Please sign in to comment.