Skip to content

Commit

Permalink
chore(docker): run optic as unprivileged user (#2756)
Browse files Browse the repository at this point in the history
  • Loading branch information
notnmeyer authored Feb 27, 2024
1 parent d78f996 commit 1805578
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 13 deletions.
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
FROM alpine:latest

# Doing the intial installation of Optic and Spectral separately
# saves a bit of space in the final image--Probably due to temp
# file creation.
FROM alpine:latest as dl
ARG OPTIC_CLI_VERSION=latest

RUN apk --no-cache add git curl
RUN echo "optic-docker" > /etc/machine-id
RUN apk --no-cache add curl
# install Optic
RUN set -e; sh -c "$(curl -s --location https://install.useoptic.com/install.sh)" -- $OPTIC_CLI_VERSION /usr/local/bin
# install Spectral
RUN curl -L https://raw.github.com/stoplightio/spectral/master/scripts/install.sh | sh

FROM alpine:latest
ENV INSTALLATION_METHOD="docker"
RUN addgroup -S optic && \
adduser -S optic -G optic && \
apk --no-cache add git curl && \
echo "optic-docker" > /etc/machine-id

COPY --from=dl /usr/local/bin/optic /usr/local/bin/
COPY --from=dl /usr/local/bin/spectral /usr/local/bin/

USER optic
ENTRYPOINT ["/usr/local/bin/optic"]
2 changes: 2 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ tasks:
--builder optic-multiplatform-builder
--build-arg OPTIC_CLI_VERSION={{.OPTIC_CLI_VERSION}}
.
# ensure we have the latest image pulled from the registry, easy to forget to do this
- docker pull localhost:5000/useoptic/optic:local

docker:build:release:
desc: Build an Optic image for all supported platforms, suitable for publishing
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "openapi-workspaces",
"license": "MIT",
"private": true,
"version": "0.54.7",
"version": "0.54.8",
"workspaces": [
"projects/json-pointer-helpers",
"projects/openapi-io",
Expand Down
2 changes: 1 addition & 1 deletion projects/fastify-capture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/fastify-capture",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/json-pointer-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/json-pointer-helpers",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-io",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-utilities",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/optic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/optic",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/rulesets-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/rulesets-base",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/standard-rulesets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/standard-rulesets",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down

0 comments on commit 1805578

Please sign in to comment.