Commit 8772dd75 authored by Diego Molteni's avatar Diego Molteni
Browse files

fixed docker images

parent 05ce55cb
......@@ -4,27 +4,26 @@ This folder contains a set of [docker](https://www.docker.com/) images to build
- `builder.Dockerfile`, creates the build image to use in the runtime.Docker to build the final distribution. The dockerfile requires 1 user parameter:
- `nodesecure_version`: node package version from [nodesecure repo](https://github.com/nodesource/distributions) for example 8, 10 or 12 etc... (default=10).
- `nodesecure_version`: node package version from [nodesecure repo](https://github.com/nodesource/distributions) for example 8, 10 or 12 etc... (default=10).
```bash
# execute this script from the repository root directory
docker build -f .\docker\builder.Dockerfile -t <builder-image-name> --build-arg nodesecure_version=<node-version> .
# example using ACR private registry
az acr login -n <acr_name>
docker build -f .\docker\builder.Dockerfile -t <acr_name>.azurecr.io/seistore-svc/<builder-image-name>:<builder-image-version> --build-arg nodesecure_version=<node-version> .
```
```bash
# execute this script from the repository root directory
docker build -f .\docker\builder.Dockerfile -t <builder-image-name> --build-arg nodesecure_version=<node-version> .
# example using ACR private registry
az acr login -n <acr_name>
docker build -f .\docker\builder.Dockerfile -t <acr_name>.azurecr.io/seistore-svc/<builder-image-name>:<builder-image-version> --build-arg nodesecure_version=<node-version> .
```
- `runtime.Dockerfile`, builds the distribution and create the final image to use in a runtime env. The dockerfile require 2 arguments:
- `docker_builder_image`, a builder image to build the typescript service, it can be build with the previous builder.Dockerfile image.
- `docker_node_image_version`, the image version of the node docker image to use for the final distribution image. It must be capable to host and execute a nodejs application, for example **10.15.3**(default value) that corresponds to node:10.15.3
```bash
# execute this script from the repository root directory
docker build -f .\docker\builder.Dockerfile -t <runtime-image-name> --build-arg docker_builder_image=<builder-image-name> --build-arg docker_node_image_version=<node-image-version> .
# example using ACR private registry
az acr login -n <acr_name>
docker build -f .\docker\runtime.Dockerfile -t <acr_name>.azurecr.io/seistore-svc/<runtime-image-name>:<runtime-image-version> --build-arg docker_builder_image=<acr_name>.azurecr.io/seistore-svc/<builder-image-name>:<builder-image-version> --build-arg docker_node_image_version=<node-image-version> .
```
- `docker_builder_image`, a builder image to build the typescript service, it can be build with the previous builder.Dockerfile image.
- `docker_node_image_version`, the image version of the node docker image to use for the final distribution image. It must be capable to host and execute a nodejs application, for example **10.15.3**(default value) that corresponds to node:10.15.3
```bash
# execute this script from the repository root directory
docker build -f .\docker\builder.Dockerfile -t <runtime-image-name> --build-arg docker_builder_image=<builder-image-name> --build-arg docker_node_image_version=<node-image-version> .
# example using ACR private registry
az acr login -n <acr_name>
docker build -f .\docker\runtime.Dockerfile -t <acr_name>.azurecr.io/seistore-svc <runtime-image-name>:<runtime-image-version> --build-arg docker_builder_image=<acr_name>.azurecr.io/seistore-svc <builder-image-name>:<builder-image-version> --build-arg docker_node_image_version=<node-image-version> .
```
\ No newline at end of file
# ============================================================================
# Copyright 2017-2019, Schlumberger
# Copyright 2017-2021, Schlumberger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -16,23 +16,10 @@
# [seistore builder image]
# use ubuntu as base image
FROM ubuntu:bionic
ARG docker_node_image_version=14-alpine
# nodejs version
ARG nodesecure_version=10
FROM node:${docker_node_image_version} as runtime-builder
# update package list and install required packages
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y gnupg
RUN apt-get install -y git
# setup node from secure package
RUN curl -sL https://deb.nodesource.com/setup_${nodesecure_version}.x -o tmp/nodesource_setup.sh
RUN bash tmp/nodesource_setup.sh
RUN rm -f tmp/nodesource_setup.sh
# install nodejs and typescript globally
RUN apt-get update && apt-get install -y nodejs
RUN npm install -g typescript
RUN apk --no-cache add --virtual native-deps g++ gcc libgcc libstdc++ linux-headers make python \
&& npm install --quiet node-gyp -g \
&& apk del native-deps
\ No newline at end of file
# ============================================================================
# Copyright 2017-2019, Schlumberger
# Copyright 2017-2021, Schlumberger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -14,25 +14,37 @@
# limitations under the License.
# ============================================================================
# [seistore runtime image]
ARG docker_node_image_version=12.18.2
ARG docker_node_image_version=14-alpine
ARG docker_builder_image
# build the service (require builder image)
# -------------------------------
# Compilation stage
# -------------------------------
FROM ${docker_builder_image} as runtime-builder
ADD ./ /service
ADD seistore-osdu /service
WORKDIR /service
RUN npm run clean && rm -rf node_modules && rm -rf artifact && mkdir artifact
RUN npm install
RUN npm run build
RUN cp -r package.json npm-shrinkwrap.json dist artifact
RUN pm run clean \
&& npm install --quiet \
&& npm run build \
&& mkdir artifact \
&& cp -r package.json npm-shrinkwrap.json dist artifact
# Create the runtime image (require base image)
# -------------------------------
# Package stage
# -------------------------------
FROM node:${docker_node_image_version} as release
COPY --from=runtime-builder /service/artifact /seistore-service
WORKDIR /seistore-service
RUN npm install --production
ENTRYPOINT ["node", "./dist/server/server-start.js"]
RUN apk --no-cache add --virtual native-deps g++ gcc libgcc libstdc++ linux-headers make python \
&& addgroup appgroup \
&& adduser --disabled-password --gecos --shell appuser --ingroup appgroup \
&& chown -R appuser:appgroup /seistore-service \
&& echo '%appgroup ALL=(ALL) NOPASSWD: /usr/bin/npm' >> /etc/sudoers \
&& echo '%appgroup ALL=(ALL) NOPASSWD: /usr/bin/node' >> /etc/sudoers \
&& npm install --production --quiet \
&& apk del native-deps
ENTRYPOINT ["node", "./dist/server/server-start.js"]
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment