Deploy build artifacts to nexus
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Armin Friedl 2020-06-12 15:31:42 +02:00
parent c9fa0c023e
commit e59d8bba6a
Signed by: armin
GPG key ID: 48C726EEE7FBCBC8
9 changed files with 97 additions and 11 deletions

View file

@ -5,16 +5,30 @@ name: default
steps:
- name: build-service
image: maven:3.6-jdk-11
environment:
NEXUS_USER:
from_secret: nexus_user
NEXUS_PASSWORD:
from_secret: nexus_password
commands:
- mkdir -p /root/.m2
- cp service/settings.xml /root/.m2/settings.xml
- cd service/fling
- mvn clean package
- mvn -Pprod clean deploy
- name: build-web
image: node:latest
environment:
NEXUS_USER:
from_secret: nexus_user
NEXUS_PASSWORD:
from_secret: nexus_password
commands:
- ls -al
- cd web/fling
- npm install && CI=false npm run build
- tar czf fling-web-latest.tar.gz build/
- curl --user "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file ./fling-web-latest.tar.gz https://nexus.friedl.net/repository/build-artifacts/fling-web-latest.tar.gz
- name: publish
image: plugins/docker
@ -24,5 +38,6 @@ steps:
password:
from_secret: docker_password
dockerfile: container/Dockerfile
context: ./container
repo: arminfriedl/fling
tags: dev

View file

@ -1,13 +1,22 @@
FROM debian:stable
RUN ls -al
RUN apt-get update -y && apt-get upgrade -y && \
apt-get install -y nginx openjdk-11-jre && \
mkdir -p /var/www/fling && \
mv web/fling/build/* /var/www/fling/ && \
rm -fr web \
apt-get install -y nginx openjdk-11-jre wget && \
mkdir -p /var/fling/files && \
mkdir -p /tmp/fling && \
wget -O /tmp/fling/service.jar "https://nexus.friedl.net/service/rest/v1/search/assets/download?sort=version&maven.groupId=net.friedl&maven.artifactId=fling&maven.baseVersion=*SNAPSHOT&maven.extension=jar" && \
wget -O /tmp/fling/web.tar.gz "https://nexus.friedl.net/repository/build-artifacts/fling-web-latest.tar.gz" && \
tar xzf /tmp/fling/web.tar.gz -C /tmp/fling && \
ls -al /tmp/fling && \
mkdir -p /var/www/fling && mv /tmp/fling/build/* /var/www/fling && \
mkdir -p /var/fling && mkdir -p /var/fling/files && \
mv /tmp/fling/service.jar ./service.jar
COPY ./etc/nginx/conf.d /etc/nginx/conf.d
COPY ./entrypoint.sh ./usr/local/bin/entrypoint.sh
ENTRYPOINT ["/bin/sh"]
VOLUME /var/fling/
EXPOSE 3000
ENTRYPOINT ["entrypoint.sh"]

7
container/entrypoint.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
set -xe
nginx
java -jar service.jar

View file

@ -2,7 +2,7 @@ server {
listen 3000;
listen [::]:3000;
server_name _;
root /var/html/fling;
root /var/www/fling;
# config to enable HSTS(HTTP Strict Transport Security)
add_header Strict-Transport-Security "max-age=15552000; includeSubdomains;";

View file

@ -137,9 +137,28 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>https://nexus.friedl.net/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<profiles>
<profile>
<!-- Profile for local development -->
@ -168,6 +187,20 @@
</dependency>
</dependencies>
</profile>
<profile>
<!-- Profile for prod deployment -->
<id>prod</id>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
</properties>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

View file

@ -1,6 +1,6 @@
spring:
datasource:
url: jdbc:h2:mem:testdb;
url: jdbc:h2:file:/var/fling/testdb;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;
driverClassName: org.h2.Driver
username: sa
password:
@ -18,7 +18,7 @@ fling:
archive.fileystem.directory: "/var/fling/files"
security:
allowed-origins:
- "https://friedl.net"
- "https://fling.friedl.net"
- "http://localhost:3000"
admin-user: "${FLING_ADMIN_USER:admin}"
admin-password: "${FLING_ADMIN_PASSWORD:123}"

22
service/settings.xml Normal file
View file

@ -0,0 +1,22 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>nexus-snapshots</id>
<username>${env.NEXUS_USER}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<url>https://nexus.friedl.net/repository/maven-central/</url>
</mirror>
</mirrors>
</settings>