Skip to content

Commit 1805578

Browse files
authored
chore(docker): run optic as unprivileged user (#2756)
1 parent d78f996 commit 1805578

File tree

10 files changed

+28
-13
lines changed

10 files changed

+28
-13
lines changed

Dockerfile

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
FROM alpine:latest
2-
1+
# Doing the intial installation of Optic and Spectral separately
2+
# saves a bit of space in the final image--Probably due to temp
3+
# file creation.
4+
FROM alpine:latest as dl
35
ARG OPTIC_CLI_VERSION=latest
4-
5-
RUN apk --no-cache add git curl
6-
RUN echo "optic-docker" > /etc/machine-id
6+
RUN apk --no-cache add curl
7+
# install Optic
78
RUN set -e; sh -c "$(curl -s --location https://install.useoptic.com/install.sh)" -- $OPTIC_CLI_VERSION /usr/local/bin
9+
# install Spectral
10+
RUN curl -L https://raw.github.com/stoplightio/spectral/master/scripts/install.sh | sh
811

12+
FROM alpine:latest
913
ENV INSTALLATION_METHOD="docker"
14+
RUN addgroup -S optic && \
15+
adduser -S optic -G optic && \
16+
apk --no-cache add git curl && \
17+
echo "optic-docker" > /etc/machine-id
18+
19+
COPY --from=dl /usr/local/bin/optic /usr/local/bin/
20+
COPY --from=dl /usr/local/bin/spectral /usr/local/bin/
21+
22+
USER optic
1023
ENTRYPOINT ["/usr/local/bin/optic"]

Taskfile.yml

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ tasks:
9595
--builder optic-multiplatform-builder
9696
--build-arg OPTIC_CLI_VERSION={{.OPTIC_CLI_VERSION}}
9797
.
98+
# ensure we have the latest image pulled from the registry, easy to forget to do this
99+
- docker pull localhost:5000/useoptic/optic:local
98100

99101
docker:build:release:
100102
desc: Build an Optic image for all supported platforms, suitable for publishing

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "openapi-workspaces",
33
"license": "MIT",
44
"private": true,
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"workspaces": [
77
"projects/json-pointer-helpers",
88
"projects/openapi-io",

projects/fastify-capture/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/fastify-capture",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/json-pointer-helpers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/json-pointer-helpers",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/openapi-io/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/openapi-io",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/openapi-utilities/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/openapi-utilities",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/optic/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/optic",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/rulesets-base/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/rulesets-base",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/standard-rulesets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/standard-rulesets",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.54.7",
5+
"version": "0.54.8",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

0 commit comments

Comments
 (0)