Skip to content

Instantly share code, notes, and snippets.

View hankehly's full-sized avatar

Hank Ehly hankehly

View GitHub Profile
@hankehly
hankehly / 03_exercise.py
Last active October 29, 2022 07:57
2022/10/29 Airflowの基礎を学ぶハンズオンワークショップ 課題 #3
import datetime
from airflow import DAG
from airflow.providers.sqlite.hooks.sqlite import SqliteHook
from airflow.providers.sqlite.operators.sqlite import SqliteOperator
SQLITE_CONN_ID = "sqlite_test_conn"
with DAG(
dag_id="03_exercise",
@hankehly
hankehly / Dockerfile
Created September 15, 2022 00:44
Blog Article Snippets - How to share private code without exposing it to the world
FROM python:3.10.6
ARG CODEARTIFACT_USER
ARG CODEARTIFACT_AUTH_TOKEN
ARG CODEARTIFACT_REPOSITORY_URL
ENV POETRY_VERSION=1.1.15 \
POETRY_HOME=/usr/local
COPY pyproject.toml poetry.lock .
@hankehly
hankehly / Dockerfile
Last active September 15, 2022 00:42
Blog Article Snippets - How to share private code without exposing it to the world
FROM python:3.10.6
ARG CODEARTIFACT_USER
ARG CODEARTIFACT_AUTH_TOKEN
COPY requirements.txt requirements-private.txt .
RUN pip install -r requirements.txt \
&& pip install -r requirements-private.txt
@hankehly
hankehly / build.sh
Created September 15, 2022 00:39
Blog Article Snippets - How to share private code without exposing it to the world
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token \
--duration-seconds 900 \
 --domain <my_domain> \
 --query authorizationToken \
 --output text`
docker build \
 --build-arg CODEARTIFACT_USER=aws \
 --build-arg CODEARTIFACT_AUTH_TOKEN=$CODEARTIFACT_AUTH_TOKEN \
 --tag example \
 .
@hankehly
hankehly / poetry_install.sh
Created September 15, 2022 00:14
Blog Article Snippets - How to share private code without exposing it to the world
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain <my_domain> --query authorizationToken --output text`
export CODEARTIFACT_USER=aws
poetry config http-basic.test123 $CODEARTIFACT_USER $CODEARTIFACT_AUTH_TOKEN
poetry install
@hankehly
hankehly / pyproject.toml
Last active September 15, 2022 00:12
Blog Article Snippets - How to share private code without exposing it to the world
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = ["example <example@example.com>"]
[[tool.poetry.source]]
name = "test123_codeartifact"
url = "https://<my_domain>-<account_id>.d.codeartifact.<region>.amazonaws.com/pypi/test123/simple/"
@hankehly
hankehly / requirements-private.txt
Created September 15, 2022 00:07
Blog Article Snippets - How to share private code without exposing it to the world
--index-url https://aws:${CODEARTIFACT_AUTH_TOKEN}@<my_domain>-<account_id>.d.codeartifact.<region>.amazonaws.com/pypi/test123/simple/
test123
@hankehly
hankehly / pip_install.sh
Last active September 15, 2022 00:16
Blog Article Snippets - How to share private code without exposing it to the world
# 1. Obtain an authentication token
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain <my_domain> --query authorizationToken --output text`
# 2. Set the --index-url argument during installation.
# Use the token from (1) as the password for HTTP basic authentication.
python3 -m pip install --index-url "https://aws:${CODEARTIFACT_AUTH_TOKEN}@<my_domain>-<account_id>.d.codeartifact.<region>.amazonaws.com/pypi/test123/simple/" test123==0.0.1
@hankehly
hankehly / 01_twine_upload.sh
Last active September 15, 2022 00:16
Blog Article Snippets - How to share private code without exposing it to the world
python3 -m pip install --upgrade build twine
python3 -m build
python3 -m twine upload --repository test123 dist/*
@hankehly
hankehly / 01_twine_setup.sh
Last active September 15, 2022 00:17
Blog Article Snippets - How to share private code without exposing it to the world
# Option 1: login command
aws codeartifact login --tool twine --domain <my_domain> --repository test123
# Option 2: environment variables
export TWINE_USERNAME=aws
export TWINE_PASSWORD=`aws codeartifact get-authorization-token --domain <my_domain> --query authorizationToken --output text`
export TWINE_REPOSITORY_URL=`aws codeartifact get-repository-endpoint --domain <my_domain> --repository test123 --format pypi --query repositoryEndpoint --output text`